name: Release permissions: contents: write on: workflow_dispatch: inputs: version: type: string required: true description: Version (Semver without leading v) sentry-release: type: boolean description: Make Sentry Release? default: true github-release: type: boolean description: Make GitHub Release? default: true github-release-draft: type: boolean description: Mark GitHub Release as Draft? default: false github-release-prerelease: type: boolean description: Mark GitHub Release as Prerelease? default: false auto-update-release: type: boolean description: Release auto-update? default: false auto-update-release-mode: type: choice description: Release auto-update mode options: - github url - upload to b2 auto-update-release-channel: type: choice description: Release auto-update channel options: - stable - preview - development jobs: release-linux: name: Release (linux-x64) env: platform-id: linux-x64 out-name: StabilityMatrix.AppImage runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: olegtarasov/get-tag@v2.1.2 if: github.event_name == 'release' id: tag_name with: tagRegex: "v(.*)" - name: Set Version from Tag if: github.event_name == 'release' run: | echo "Using tag ${{ env.GIT_TAG_NAME }}" echo "RELEASE_VERSION=${{ env.GIT_TAG_NAME }}" >> $GITHUB_ENV - name: Set Version from manual input if: github.event_name == 'workflow_dispatch' run: | echo "Using version ${{ github.event.inputs.version }}" echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV - name: Set up .NET 6 (for PupNet) uses: actions/setup-dotnet@v3 with: dotnet-version: '6.0.x' - name: Install PupNet run: | sudo apt-get -y install libfuse2 dotnet tool install --framework net6.0 -g KuiperZone.PupNet - name: Set up .NET 7 uses: actions/setup-dotnet@v3 with: dotnet-version: '7.0.x' - name: PupNet Build env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} run: pupnet -r linux-x64 -c Release --kind appimage --app-version $RELEASE_VERSION --clean -y - name: Post Build run: mv ./Release/linux-x64/StabilityMatrix.x86_64.AppImage ${{ env.out-name }} - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: StabilityMatrix-${{ env.platform-id }} path: ${{ env.out-name }} - name: Create Sentry release if: ${{ github.event.inputs.sentry-release == 'true' }} uses: getsentry/action-release@v1 env: MAKE_SENTRY_RELEASE: ${{ secrets.SENTRY_PROJECT != '' }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} with: environment: production ignore_missing: true ignore_empty: true version: StabilityMatrix.Avalonia@${{ github.event.inputs.version }} release-windows: name: Release (win-x64) env: platform-id: win-x64 out-name: StabilityMatrix.exe runs-on: windows-latest steps: - uses: actions/checkout@v3 - uses: olegtarasov/get-tag@v2.1.2 if: github.event_name == 'release' id: tag_name with: tagRegex: "v(.*)" - name: Set Version from Tag if: github.event_name == 'release' run: | echo "Using tag ${{ env.GIT_TAG_NAME }}" echo "RELEASE_VERSION=${{ env.GIT_TAG_NAME }}" >> $env:GITHUB_ENV - name: Set Version from manual input if: github.event_name == 'workflow_dispatch' run: | echo "Using version ${{ github.event.inputs.version }}" echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $env:GITHUB_ENV - name: Set up .NET 7 uses: actions/setup-dotnet@v3 with: dotnet-version: '7.0.x' - name: Install dependencies run: dotnet restore - name: .NET Publish env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} run: > dotnet publish ./StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj -o out -c Release -r ${{ env.platform-id }} -p:Version=$env:RELEASE_VERSION -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishReadyToRun=true -p:SentryOrg=${{ secrets.SENTRY_ORG }} -p:SentryProject=${{ secrets.SENTRY_PROJECT }} -p:SentryUploadSymbols=true -p:SentryUploadSources=true - name: Post Build run: mv ./out/StabilityMatrix.Avalonia.exe ./out/${{ env.out-name }} - name: Upload Artifact uses: actions/upload-artifact@v2 with: name: StabilityMatrix-${{ env.platform-id }} path: ./out/${{ env.out-name }} publish-release: name: Publish GitHub Release needs: [ release-linux, release-windows ] if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.github-release == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Extract Release Notes id: release_notes run: | RELEASE_NOTES="$(awk -v version="${{ github.event.inputs.version }}" '/## v/{if(p) exit; if($0 ~ version) p=1}; p' CHANGELOG.md)" RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}" RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}" RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}" echo "::set-output name=release_notes::$RELEASE_NOTES" # Downloads all previous artifacts to the current working directory - name: Download Artifacts uses: actions/download-artifact@v3 # Zip each build - name: Zip Artifacts run: | zip -r StabilityMatrix-win-x64.zip StabilityMatrix-win-x64/* zip -r StabilityMatrix-linux-x64.zip StabilityMatrix-linux-x64/* - name: Create Github Release id: create_release uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: | StabilityMatrix-win-x64.zip StabilityMatrix-linux-x64.zip StabilityMatrix-win-x64/StabilityMatrix.exe StabilityMatrix-linux-x64/StabilityMatrix.AppImage fail_on_unmatched_files: true tag_name: v${{ github.event.inputs.version }} body: ${{ steps.release_notes.outputs.release_notes }} draft: ${{ github.event.inputs.github-release-draft == 'true' }} prerelease: ${{ github.event.inputs.github-release-prerelease == 'true' }} publish-auto-update-github: name: Publish Auto-Update Release (GitHub) needs: [ release-linux, release-windows ] if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.auto-update-release == 'true' && github.event.inputs.auto-update-release-mode == 'github url' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set Version from manual input run: | echo "Using version ${{ github.event.inputs.version }}" echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $env:GITHUB_ENV - uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install Python Dependencies run: pip install stability-matrix-tools~=0.2.7 - name: Publish Auto-Update Release run: sm-tools updates publish-matrix -v $RELEASE_VERSION -y publish-auto-update-b2: name: Publish Auto-Update Release (B2) needs: [ release-linux, release-windows ] if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.auto-update-release == 'true' && github.event.inputs.auto-update-release-mode == 'upload to b2' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set Version from manual input run: | echo "Using version ${{ github.event.inputs.version }}" echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $env:GITHUB_ENV - uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install Python Dependencies run: pip install stability-matrix-tools~=0.2.7 - name: Download Changelog run: > sm-tools updates download-changelog -v $RELEASE_VERSION -y --changelog # Zip each build - name: Zip Artifacts run: | zip -r StabilityMatrix-win-x64.zip StabilityMatrix-win-x64/* zip -r StabilityMatrix-linux-x64.zip StabilityMatrix-linux-x64/* # Check that the zips and CHANGELOG.md are in the current working directory - name: Check files run: | if [ ! -f StabilityMatrix-win-x64.zip ]; then echo "StabilityMatrix-win-x64.zip not found" exit 1 fi if [ ! -f StabilityMatrix-linux-x64.zip ]; then echo "StabilityMatrix-linux-x64.zip not found" exit 1 fi if [ ! -f CHANGELOG.md ]; then echo "CHANGELOG.md not found" exit 1 fi - name: Publish Auto-Update Release run: > sm-tools updates publish-files-v3 -v $RELEASE_VERSION -y --channel ${{ github.event.inputs.auto-update-release-channel }} --changelog CHANGELOG.md --win-x64 StabilityMatrix-win-x64.zip --linux-x64 StabilityMatrix-linux-x64.zip --b2-bucket-name ${{ secrets.B2_BUCKET_NAME }}