Build and Draft Nightly Release #1602
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
| # This is a basic workflow to help you get started with Actions | |
| name: Build and Draft Nightly Release | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the "main" branch | |
| schedule: | |
| - cron: "0 7 * * *" | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| # This workflow checks to see if branch has any changes since last wo | |
| prep: | |
| runs-on: ubuntu-latest | |
| name: Prepare for Build | |
| outputs: | |
| oldversion: ${{ steps.previoustag.outputs.tag }} | |
| version: ${{ steps.semvers.outputs.patch }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| # the nightly tag is moved to the built commit on every successful release, | |
| # so building only when HEAD differs from it also picks up commits that a | |
| # previously failed run never shipped. the run is failed on purpose when | |
| # there is nothing to build so a "no new nightly" day is visible as red | |
| - name: "check for new commits since last nightly" | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "This workflow was triggered manually! Forcing a build." | |
| elif [[ "$(git rev-parse HEAD)" == "$(git rev-parse 'refs/tags/nightly^{commit}' 2>/dev/null)" ]]; then | |
| echo "::error::No new commits since last nightly release, no build created." | |
| exit 1 | |
| fi | |
| - name: "Check if nightly exists" | |
| id: nightly | |
| uses: cardinalby/git-get-release-action@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tag: "nightly" | |
| prerelease: true | |
| doNotFailIfNotFound: true | |
| - name: "Get Previous tag" | |
| id: previoustag | |
| run: | | |
| nightly="" | |
| if [ "${{steps.nightly.outputs.id}}" != "" ]; then | |
| nightly=$(echo "${{steps.nightly.outputs.name}}" | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/') | |
| fi | |
| # a stable release (release.yml) can be published with a higher version | |
| # than the running nightly series, so continue from whichever is newer | |
| stable=$(git tag --list '[0-9]*' | sort -V | tail -n 1) | |
| tag=$(printf '%s\n' "$nightly" "$stable" | grep . | sort -V | tail -n 1) | |
| echo "Previous version: $tag (nightly: ${nightly:-none}, stable: ${stable:-none})" | |
| echo "tag=$tag" >> $GITHUB_OUTPUT | |
| - name: "Get next version" | |
| id: semvers | |
| uses: "WyriHaximus/github-action-next-semvers@v1" | |
| with: | |
| version: ${{ steps.previoustag.outputs.tag }} | |
| - name: output | |
| run: echo ${{steps.previoustag.outputs.tag}} ${{steps.semvers.outputs.patch}} | |
| build: | |
| needs: prep | |
| runs-on: windows-2022 | |
| name: Build RePlays | |
| permissions: | |
| contents: write | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: "true" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18.x | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: 8.0.403 | |
| # vpk (velopack) is pinned in .config/dotnet-tools.json and run by the publish | |
| - name: Restore dotnet tools | |
| run: dotnet tool restore | |
| # the previous full package is what the delta package is built against. with --pre | |
| # the newest version across the stable and nightly releases is taken, the same set | |
| # of releases the app itself reads on the nightly channel | |
| - name: Download previous release to create delta | |
| run: dotnet vpk download github --repoUrl https://github.com/${{ github.repository }} --token ${{ secrets.GITHUB_TOKEN }} --pre --outputDir bin/Deployment/Releases | |
| - name: Build LibObs | |
| run: .\\build-libobs.cmd | |
| shell: cmd | |
| - name: Build RePlays | |
| env: | |
| CI: false | |
| run: dotnet publish /p:Configuration=Release /p:Version=${{needs.prep.outputs.version}} /p:PublishProfile=FolderProfile -v d | |
| - name: Append version to setup file | |
| run: ren ./bin/Deployment/Releases/RePlays-win-Setup.exe RePlaysSetup-${{needs.prep.outputs.version}}.exe | |
| - name: Update nightly tag | |
| uses: richardsimko/update-tag@v1 | |
| with: | |
| tag_name: nightly | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Delete old prerelease deltas | |
| run: | | |
| gh release delete-asset "nightly" "RePlays-${{needs.prep.outputs.oldversion}}-full.nupkg" && | |
| gh release delete-asset "nightly" "RePlays-${{needs.prep.outputs.oldversion}}-delta.nupkg" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create prerelease | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: "nightly" | |
| prerelease: true | |
| generate_release_notes: true | |
| name: ${{ format('Nightly RePlays v{0}', needs.prep.outputs.version )}} | |
| body: "Nightly release, built with the latest and potentially breaking changes, test at your own risk." | |
| files: | | |
| ./bin/Deployment/Releases/RELEASES | |
| ./bin/Deployment/Releases/releases.win.json | |
| ./bin/Deployment/Releases/RePlaysSetup-${{needs.prep.outputs.version}}.exe | |
| ./bin/Deployment/Releases/RePlays-${{needs.prep.outputs.version}}-full.nupkg | |
| ./bin/Deployment/Releases/RePlays-${{needs.prep.outputs.version}}-delta.nupkg | |
| # the setup executables are the only assets that survive from one nightly | |
| # to the next, so keep the three most recent ones and drop the rest | |
| - name: Prune old nightly setup executables | |
| shell: bash | |
| run: | | |
| gh release view nightly --json assets --jq '.assets[].name' \ | |
| | grep -E '^RePlaysSetup-[0-9]+(\.[0-9]+)+\.exe$' \ | |
| | sort -V \ | |
| | head -n -3 \ | |
| | while read -r asset; do | |
| echo "Deleting $asset" | |
| gh release delete-asset nightly "$asset" --yes | |
| done | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |