Create Release #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
permissions: | |
contents: write | |
packages: write | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
required: true | |
description: "Version" | |
name: | |
type: string | |
required: false | |
description: "Title" | |
default: "" | |
description: | |
type: string | |
required: true | |
description: "Description of changes" | |
release-rml: | |
type: boolean | |
required: false | |
description: "Release for ResoniteModLoader" | |
default: true | |
release-monkey: | |
type: boolean | |
required: false | |
description: "Release for MonkeyLoader" | |
default: true | |
env: | |
NUGET_PUBLISH_TARGET: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
ARTIFACT_NAME: SampleMod | |
name: "Create Release" | |
jobs: | |
check-inputs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Check version format" | |
env: | |
RELEASE_VERSION: "${{ inputs.version }}" | |
shell: bash | |
run: | | |
# https://semver.org/ applied to https://stackoverflow.com/questions/21112707/check-if-a-string-matches-a-regex-in-bash-script | |
[[ "$RELEASE_VERSION" =~ ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-((0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]] | |
compile-rml: | |
if: ${{ inputs.release-rml }} | |
uses: ./.github/workflows/build-rml.yml | |
needs: check-inputs | |
with: | |
RELEASE_VERSION: "${{ inputs.version }}" | |
RELEASE_NOTES: "${{ inputs.description }}" | |
secrets: | |
RESONITE_CLONE_TOKEN: "${{ secrets.RESONITE_CLONE_TOKEN }}" | |
compile-monkey: | |
if: ${{ inputs.release-monkey }} | |
uses: ./.github/workflows/build-monkey.yml | |
needs: check-inputs | |
with: | |
RELEASE_VERSION: "${{ inputs.version }}" | |
RELEASE_NOTES: "${{ inputs.description }}" | |
secrets: | |
RESONITE_CLONE_TOKEN: "${{ secrets.RESONITE_CLONE_TOKEN }}" | |
create-github-release: | |
if: ${{ inputs.release-rml }} | |
runs-on: ubuntu-latest | |
needs: compile-rml | |
outputs: | |
TRIGGER_RML_PUSH: ${{ steps.check-manifest-token.outputs.exists }} | |
steps: | |
- name: Download RML build artifacts | |
uses: actions/download-artifact@v3.0.2 | |
with: | |
name: "${{ env.ARTIFACT_NAME }}-ResoniteModLoader" | |
path: "tmp/" | |
- name: Create release | |
uses: "ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5" | |
with: | |
artifactErrorsFailBuild: true | |
artifacts: "tmp/*.*,tmp/*/*.*" | |
body: "${{ inputs.description }}" | |
name: "${{ inputs.name || inputs.version }}" | |
tag: "v${{ inputs.version }}" | |
commit: "${{ github.ref }}" | |
- name: Check manifest token to decide on next step | |
id: check-manifest-token | |
shell: bash | |
run: | | |
#Source: https://stackoverflow.com/questions/70249519/how-to-check-if-a-secret-variable-is-empty-in-if-conditional-github-actions | |
if [ "${{ secrets.RML_MANIFEST_TOKEN }}" != '' ]; then | |
echo "exists=true" >> $GITHUB_OUTPUT; | |
else | |
echo "exists=false" >> $GITHUB_OUTPUT; | |
fi | |
push-rml-manifest: | |
uses: ./.github/workflows/push-rml-manifest.yml | |
needs: create-github-release | |
if: "${{ needs.create-github-release.outputs.TRIGGER_RML_PUSH == 'true' }}" | |
with: | |
RELEASE_VERSION: "${{ inputs.version }}" | |
RELEASE_NOTES: "${{ inputs.description }}" | |
secrets: | |
RML_MANIFEST_TOKEN: "${{ secrets.RML_MANIFEST_TOKEN }}" | |
push-nuget: | |
if: ${{ inputs.release-monkey }} | |
runs-on: ubuntu-latest | |
needs: compile-monkey | |
steps: | |
- name: Download NuGet package build artifacts | |
uses: actions/download-artifact@v3.0.2 | |
with: | |
name: "${{ env.ARTIFACT_NAME }}-MonkeyLoader" | |
path: "tmp/" | |
- name: Add repo owner's NuGet package source | |
run: dotnet nuget add source --username "${{ github.repository_owner }}" --password "${{ secrets.GITHUB_TOKEN }}" --store-password-in-clear-text --name "publish_target" "${{ env.NUGET_PUBLISH_TARGET }}" | |
- name: Publish to NuGet feed | |
run: dotnet nuget push "tmp/**.nupkg" --api-key "${{ secrets.GITHUB_TOKEN }}" --source "publish_target" |