|
12 | 12 | steps: |
13 | 13 | - name: Checkout repository |
14 | 14 | uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
15 | 17 |
|
16 | 18 | - name: Compile with Quartus |
17 | 19 | uses: raetro/quartus-flow@v1 |
|
30 | 32 | f.write(reversed_data) |
31 | 33 | PYEOF |
32 | 34 |
|
| 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 | +
|
33 | 65 | - name: Package core |
34 | 66 | run: | |
35 | 67 | mkdir -p release/Cores/ericlewis.LunarLander |
|
43 | 75 | - name: Upload artifact |
44 | 76 | uses: actions/upload-artifact@v4 |
45 | 77 | with: |
46 | | - name: LunarLander-core |
| 78 | + name: LunarLander-${{ steps.version.outputs.version }} |
47 | 79 | 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