Build for release #21
This file contains hidden or 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
| name: Build for release | |
| on: | |
| workflow_run: | |
| workflows: [.NET CI] | |
| types: [completed] | |
| push: | |
| tags: | |
| - v* | |
| jobs: | |
| build_and_pack: | |
| name: Release build & package | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }} | |
| env: | |
| GithubNugetUsername: craigfowler | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Setup build dependencies | |
| uses: ./.github/actions/setup-build-dependencies | |
| - name: Restore third party libs | |
| uses: ./.github/actions/restore-dependencies | |
| - name: Build CI version | |
| if: ${{ github.event_name == 'workflow_run' }} | |
| run: dotnet pack -p:VersionSuffix=ci.${{ github.run_number }} -o packages | |
| - name: Get semantic tag version | |
| if: ${{ github.event_name == 'push' }} | |
| id: get_version | |
| run: | | |
| tagname="${{ github.ref_name }}" | |
| echo "name=${tagname:1}" >> "$GITHUB_OUTPUT" | |
| shell: bash | |
| - name: Build tagged version | |
| if: ${{ github.event_name == 'push' }} | |
| run: dotnet pack -p:Version=${{ steps.get_version.outputs.name }} -o packages | |
| - name: Upload build result artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: Build results (NuGet) | |
| path: packages/*.nupkg | |
| - name: Publish packages to GitHub feed | |
| if: ${{ github.event_name != 'pull_request' && github.ref_name == 'master' }} | |
| run: | | |
| dotnet nuget add source --username ${{ env.GithubNugetUsername }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/csf-dev/index.json" | |
| for package in packages/*.nupkg | |
| do | |
| dotnet nuget push $package --source github | |
| done | |
| build_docs_site: | |
| name: Build the documentation website | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Setup build dependencies | |
| uses: ./.github/actions/setup-build-dependencies | |
| - name: Restore third party libs | |
| uses: ./.github/actions/restore-dependencies | |
| - name: Remove old docs | |
| run: dotnet clean CSF.Screenplay.Docs | |
| - name: Build docs website | |
| run: dotnet build -c Docs CSF.Screenplay.Docs | |
| - name: Upload docs website artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: Docs website | |
| path: docs/**/* | |
| publish_nuget: | |
| name: Publish packages to NuGet | |
| runs-on: ubuntu-slim | |
| if: ${{ github.event_name == 'push' }} | |
| needs: build_and_pack | |
| permissions: | |
| actions: read | |
| id-token: write | |
| contents: write | |
| steps: | |
| - name: Add .NET global tools location to PATH | |
| run: echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH" | |
| shell: bash | |
| - name: Install .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Get release artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: Build results (NuGet) | |
| path: ./packages | |
| - name: Log into NuGet & get short-lived API key | |
| uses: NuGet/login@v1 | |
| id: nuget-login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Publish to NuGet | |
| run: dotnet nuget push ./packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} | |
| - name: Determine release properties | |
| id: get-release-props | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| PRERELEASE="$([[ "$VERSION" =~ "-" ]] && echo "true" || echo "false")" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT" | |
| - name: Generate release notes (first part) | |
| run: | | |
| PACKAGE_LIST=$(for package in packages/*.nupkg; do echo $(basename "$package" | sed -r 's/^([A-Za-z.]+)\.[0-9.A-Za-z-]*\.nupkg$/\1/'); done) | |
| VERSION="${{ steps.get-release-props.outputs.version }}" | |
| cat <<EOF > release_notes.md | |
| # CSF.Screenplay version $VERSION | |
| ## NuGet packages | |
| These are the NuGet packages which are published for this release. | |
| | Package | Version | | |
| | ------- | ------- | | |
| EOF | |
| for package in $PACKAGE_LIST | |
| do | |
| echo "| [${package}](https://www.nuget.org/packages/${package}/${VERSION}) | $VERSION |" >> release_notes.md | |
| done | |
| cat <<EOF >> release_notes.md | |
| ## Changelog | |
| EOF | |
| - name: Create release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| draft: true | |
| name: ${{ steps.get-release-props.outputs.version }} | |
| prerelease: ${{ steps.get-release-props.outputs.prerelease }} | |
| body_path: release_notes.md | |
| generate_release_notes: true |