Skip to content

Commit 2a3b53f

Browse files
committed
Add auto-versioned GitHub Releases on merge to main
- Compute next patch version from the latest v* git tag - Stamp version and release date into core.json before packaging - Zip the release with Cores/, Platforms/, Assets/ at the root so it can be extracted directly onto an Analogue Pocket SD card - Create a GitHub Release with auto-generated notes (main only) - PR and branch builds still upload artifacts for testing https://claude.ai/code/session_01QmPirfEXJ1bsJHb9i98uGS
1 parent 9d0adfe commit 2a3b53f

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
steps:
1313
- name: Checkout repository
1414
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
1517

1618
- name: Compile with Quartus
1719
uses: raetro/quartus-flow@v1
@@ -30,6 +32,36 @@ jobs:
3032
f.write(reversed_data)
3133
PYEOF
3234
35+
- name: Compute version
36+
id: version
37+
run: |
38+
LAST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -n1)
39+
if [ -z "$LAST_TAG" ]; then
40+
NEXT_VERSION="1.0.0"
41+
else
42+
VERSION="${LAST_TAG#v}"
43+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
44+
MINOR=$(echo "$VERSION" | cut -d. -f2)
45+
PATCH=$(echo "$VERSION" | cut -d. -f3)
46+
PATCH=$((PATCH + 1))
47+
NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
48+
fi
49+
echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
50+
echo "tag=v$NEXT_VERSION" >> "$GITHUB_OUTPUT"
51+
52+
- name: Stamp version into core.json
53+
run: |
54+
python3 << PYEOF
55+
import json, datetime
56+
with open('dist/Cores/ericlewis.LunarLander/core.json', 'r') as f:
57+
data = json.load(f)
58+
data['core']['metadata']['version'] = '${{ steps.version.outputs.version }}'
59+
data['core']['metadata']['date_release'] = datetime.date.today().isoformat()
60+
with open('dist/Cores/ericlewis.LunarLander/core.json', 'w') as f:
61+
json.dump(data, f, indent=4)
62+
f.write('\n')
63+
PYEOF
64+
3365
- name: Package core
3466
run: |
3567
mkdir -p release/Cores/ericlewis.LunarLander
@@ -43,5 +75,20 @@ jobs:
4375
- name: Upload artifact
4476
uses: actions/upload-artifact@v4
4577
with:
46-
name: LunarLander-core
78+
name: LunarLander-${{ steps.version.outputs.version }}
4779
path: release/
80+
81+
- name: Create release zip
82+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
83+
working-directory: release
84+
run: zip -r ../ericlewis.LunarLander-${{ steps.version.outputs.version }}.zip .
85+
86+
- name: Create GitHub Release
87+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
88+
env:
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: |
91+
gh release create "${{ steps.version.outputs.tag }}" \
92+
"ericlewis.LunarLander-${{ steps.version.outputs.version }}.zip" \
93+
--title "Lunar Lander ${{ steps.version.outputs.tag }}" \
94+
--generate-notes

0 commit comments

Comments
 (0)