Skip to content

Commit

Permalink
Create CI/CD Script & Update Base Publish Script
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Feb 11, 2022
1 parent 1e75469 commit 24438ea
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 1 deletion.
126 changes: 126 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Build and Publish

on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
workflow_dispatch:

env:
PUBLISH_COMMON_PATH: ./Publish/ToUpload/

PUBLISH_GITHUB_MONITOR_PATH: ./Publish/ToUpload/Monitor/Generic
PUBLISH_NUGET_MONITOR_PATH: ./Publish/ToUpload/Monitor/NuGet

PUBLISH_GITHUB_REDIRECTOR_PATH: ./Publish/ToUpload/Redirector/Generic
PUBLISH_NUGET_REDIRECTOR_PATH: ./Publish/ToUpload/Redirector/NuGet

PUBLISH_GITHUB_REDIRECTORMONITOR_PATH: ./Publish/ToUpload/RedirectorMonitor/Generic
PUBLISH_NUGET_REDIRECTORMONITOR_PATH: ./Publish/ToUpload/RedirectorMonitor/NuGet

PUBLISH_CHANGELOG_PATH: ./Publish/Changelog.md
PUBLISH_PATH: ./Publish

IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
RELEASE_TAG: ${{ github.ref_name }}

jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: pwsh

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup .NET Core SDK (5.0)
uses: actions/[email protected]
with:
dotnet-version: 5.0.x

- name: Setup .NET Core SDK (6.0)
uses: actions/[email protected]
with:
dotnet-version: 6.0.x

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Setup AutoChangelog
run: npm install -g auto-changelog

- name: Create Changelog
run: |
[System.IO.Directory]::CreateDirectory("$env:PUBLISH_PATH")
if ($env:IS_RELEASE -eq 'true') {
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --starting-version "$env:RELEASE_TAG" --output "$env:PUBLISH_CHANGELOG_PATH"
}
else {
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --output "$env:PUBLISH_CHANGELOG_PATH"
}
- name: Build
run: ./PublishAll.ps1

- name: Upload GitHub Release Artifact
uses: actions/[email protected]
with:
# Artifact name
name: GitHub Release
# A file, directory or wildcard pattern that describes what to upload
path: |
${{ env.PUBLISH_GITHUB_MONITOR_PATH }}/*
${{ env.PUBLISH_GITHUB_REDIRECTOR_PATH }}/*
${{ env.PUBLISH_GITHUB_REDIRECTORMONITOR_PATH }}/*
- name: Upload NuGet Release Artifact
uses: actions/[email protected]
with:
# Artifact name
name: NuGet Release
# A file, directory or wildcard pattern that describes what to upload
path: |
${{ env.PUBLISH_NUGET_MONITOR_PATH }}/*
${{ env.PUBLISH_NUGET_REDIRECTOR_PATH }}/*
${{ env.PUBLISH_NUGET_REDIRECTORMONITOR_PATH }}/*
- name: Upload Changelog Artifact
uses: actions/[email protected]
with:
# Artifact name
name: Changelog
# A file, directory or wildcard pattern that describes what to upload
path: ${{ env.PUBLISH_CHANGELOG_PATH }}
retention-days: 0

- name: Upload to GitHub Releases
uses: softprops/[email protected]
if: env.IS_RELEASE == 'true'
with:
# Path to load note-worthy description of changes in release from
body_path: ${{ env.PUBLISH_CHANGELOG_PATH }}
# Newline-delimited list of path globs for asset files to upload
files: |
${{ env.PUBLISH_GITHUB_MONITOR_PATH }}/*
${{ env.PUBLISH_GITHUB_REDIRECTOR_PATH }}/*
${{ env.PUBLISH_GITHUB_REDIRECTORMONITOR_PATH }}/*
- name: Push to NuGet (on Tag)
env:
NUGET_KEY: ${{ secrets.RELOADED_NUGET_KEY }}
if: env.IS_RELEASE == 'true'
run: |
$items = Get-ChildItem -Path "$env:PUBLISH_COMMON_PATH/*.nupkg"
Foreach ($item in $items)
{
Write-Host "Pushing $item"
dotnet nuget push "$item" -k "$env:NUGET_KEY" -s "http://packages.sewer56.moe:5000/v3/index.json" --skip-duplicate
}
9 changes: 8 additions & 1 deletion Publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
Allows you to specify a Wildcard pattern (e.g. *Update.zip) for the file to be downloaded.
This is a fallback used in cases no Release Metadata file can be found.
.PARAMETER GitHubInheritVersionFromTag
[Use if UseGitHubDelta is true]
Uses version determined from release tag (in GitHub Releases) as opposed to the
Release Metadata file in latest release.
.PARAMETER GameBananaItemId
[Use if UseGameBananaDelta is true]
Example: 150118
Expand Down Expand Up @@ -149,6 +154,7 @@ param (
$GitHubUserName = "Sewer56",
$GitHubRepoName = "Reloaded.SharedLib.Hooks.ReloadedII",
$GitHubFallbackPattern = "reloaded.sharedlib.hooks.zip", # For migrating from legacy.
$GitHubInheritVersionFromTag = $True, # Uses version determined from release tag as opposed to metadata file in latest release.

$GameBananaItemId = 333681, # From mod page URL.

Expand Down Expand Up @@ -194,6 +200,7 @@ $NuGetAllowUnlisted = [bool]::Parse($NuGetAllowUnlisted)
$PublishGeneric = [bool]::Parse($PublishGeneric)
$PublishNuGet = [bool]::Parse($PublishNuGet)
$PublishGameBanana = [bool]::Parse($PublishGameBanana)
$GitHubInheritVersionFromTag = [bool]::Parse($GitHubInheritVersionFromTag)

function Get-Tools {
# Download Tools (if needed)
Expand Down Expand Up @@ -254,7 +261,7 @@ function Get-Last-Version {
$arguments = "DownloadPackage --extract --outputpath `"$deltaDirectory`" --allowprereleases `"$IsPrerelease`""

if ($UseGitHubDelta) {
$arguments += " --source GitHub --githubusername `"$GitHubUserName`" --githubrepositoryname `"$GitHubRepoName`" --githublegacyfallbackpattern `"$GitHubFallbackPattern`""
$arguments += " --source GitHub --githubusername `"$GitHubUserName`" --githubrepositoryname `"$GitHubRepoName`" --githublegacyfallbackpattern `"$GitHubFallbackPattern`" --githubinheritversionfromtag `"$GitHubInheritVersionFromTag`""
}
elseif ($UseNuGetDelta) {
$arguments += " --source NuGet --nugetpackageid `"$NuGetPackageId`" --nugetfeedurl `"$NuGetFeedUrl`" --nugetallowunlisted `"$NuGetAllowUnlisted`""
Expand Down

0 comments on commit 24438ea

Please sign in to comment.