From fe19dd1998e2ac6e24ea2d5be7a67a73f6c6e19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Guti=C3=A9rrez=20Hermoso?= Date: Sat, 12 Sep 2026 19:36:37 -0600 Subject: [PATCH] workflows: add a workflow to generate releases from tags When a new commit on `master` is tagged, the following github action will grab the artifacts created by the `snapshot-on-push-master` action. The intended workflow is to merge to `master`, wait for the artifacts to build, then tag that commit as a release. When that is done, the new action will generate a release, using the tag as the version number of the release. Here is an example of what a successful run looks like: https://github.com/jordigh/cc65/actions/runs/34737736095 Here is the release it generated: https://github.com/jordigh/cc65/releases/tag/V2.19TEST5 closes: #2281 --- .github/workflows/release-from-snapshot.yml | 99 +++++++++++++++++++ .github/workflows/snapshot-on-push-master.yml | 11 ++- 2 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release-from-snapshot.yml diff --git a/.github/workflows/release-from-snapshot.yml b/.github/workflows/release-from-snapshot.yml new file mode 100644 index 000000000..c8e8b2ef0 --- /dev/null +++ b/.github/workflows/release-from-snapshot.yml @@ -0,0 +1,99 @@ +name: Release on Tag from Snapshot + +on: + push: + tags: + - "V*" + workflow_dispatch: + +permissions: + contents: write + actions: read + +concurrency: + group: release-${{ github.ref_name }} + cancel-in-progress: false + +jobs: + release: + if: github.repository == 'cc65/cc65' + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + TAG: ${{ github.ref_name }} + TAG_SHA: ${{ github.sha }} + SNAPSHOT_WORKFLOW: snapshot-on-push-master.yml + + steps: + - name: Find successful snapshot run for this exact commit on master + id: snapshot + shell: bash + run: | + set -euo pipefail + + echo "Looking for successful '${SNAPSHOT_WORKFLOW}' run on master for SHA ${TAG_SHA}" + + run_id="$(gh run list \ + --repo "$REPO" \ + --workflow "$SNAPSHOT_WORKFLOW" \ + --status completed \ + --json databaseId,headSha,conclusion \ + --jq '.[] | select(.headSha == "'"${TAG_SHA}"'" and .conclusion == "success") | .databaseId' \ + | head -n1 || true)" + + if [[ -z "${run_id:-}" ]]; then + echo "No successful snapshot run found for commit ${TAG_SHA}." + echo "Stop now; rerun this workflow after snapshot succeeds." + exit 1 + fi + + echo "Found snapshot run id=${run_id}" + echo "run_id=${run_id}" >> "$GITHUB_OUTPUT" + + - name: Download artifacts from snapshot run + shell: bash + run: | + set -euo pipefail + mkdir -p artifacts + gh run download "${{ steps.snapshot.outputs.run_id }}" \ + --repo "$REPO" \ + --dir artifacts + + - name: Rename snapshot artifacts to tag names + shell: bash + run: | + set -euo pipefail + shopt -s globstar nullglob + + found=0 + for f in artifacts/**/cc65-snapshot-win32.zip; do + mv "$f" "$(dirname "$f")/cc65-${TAG}-win32.zip" + found=1 + done + for f in artifacts/**/cc65-snapshot-win64.zip; do + mv "$f" "$(dirname "$f")/cc65-${TAG}-win64.zip" + found=1 + done + for f in artifacts/**/cc65-snapshot-docs.zip; do + mv "$f" "$(dirname "$f")/cc65-${TAG}-docs.zip" + found=1 + done + + if [[ "$found" -eq 0 ]]; then + echo "Expected snapshot artifacts were not found in run ${{ steps.snapshot.outputs.run_id }}" + exit 1 + fi + + - name: Create or update GitHub release and upload assets + uses: softprops/action-gh-release@v3 + with: + tag_name: ${{ env.TAG }} + target_commitish: ${{ env.TAG_SHA }} + generate_release_notes: true + files: | + artifacts/**/cc65-${{ env.TAG }}-win32.zip + artifacts/**/cc65-${{ env.TAG }}-win64.zip + artifacts/**/cc65-${{ env.TAG }}-docs.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/snapshot-on-push-master.yml b/.github/workflows/snapshot-on-push-master.yml index 591b221be..8a93f1f55 100644 --- a/.github/workflows/snapshot-on-push-master.yml +++ b/.github/workflows/snapshot-on-push-master.yml @@ -18,10 +18,10 @@ jobs: run: git config --global core.autocrlf input - name: Checkout Source - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v2 + uses: microsoft/setup-msbuild@v3 - name: Build app (debug) run: msbuild src\cc65.sln -t:rebuild -property:Configuration=Debug @@ -44,7 +44,7 @@ jobs: - shell: bash run: git config --global core.autocrlf input - name: Checkout Source - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Do some simple style checks shell: bash @@ -89,15 +89,17 @@ jobs: mv cc65.zip cc65-snapshot-win32.zip - name: Upload a 32-bit Snapshot Zip - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: cc65-snapshot-win32 path: cc65-snapshot-win32.zip + retention-days: 90 - name: Upload a 64-bit Snapshot Zip uses: actions/upload-artifact@v4 with: name: cc65-snapshot-win64 path: cc65-snapshot-win64.zip + retention-days: 90 - name: Get the online documents repo. uses: actions/checkout@v4 @@ -127,6 +129,7 @@ jobs: with: name: cc65-snapshot-docs path: cc65-snapshot-docs.zip + retention-days: 90 # enter secrets under "repository secrets" - name: Upload 32-bit Windows snapshot to sourceforge