|
1 | | -name: PlatformIO Release Build |
| 1 | +name: PlatformIO Auto Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - tags: |
6 | | - - 'v*' |
7 | | - workflow_dispatch: |
| 5 | + branches: [ main ] # runs automatically on every push to main |
8 | 6 |
|
9 | 7 | jobs: |
10 | 8 | build: |
|
13 | 11 | steps: |
14 | 12 | - name: Checkout repository |
15 | 13 | uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
16 | 16 |
|
17 | 17 | - name: Set up Python |
18 | 18 | uses: actions/setup-python@v5 |
@@ -41,15 +41,29 @@ jobs: |
41 | 41 | - name: Build firmware |
42 | 42 | run: pio run |
43 | 43 |
|
44 | | - - name: Rename firmware |
| 44 | + - name: Prepare firmware output |
45 | 45 | run: | |
46 | 46 | mkdir output |
47 | | - find .pio/build -name "firmware.bin" -exec bash -c 'cp "$0" "output/${0##*/}"' {} \; |
| 47 | + find .pio/build -name "firmware.bin" -exec bash -c 'cp "$0" "output/${0%/*}.bin"' {} \; |
48 | 48 | ls -lh output |
49 | 49 |
|
50 | | - - name: Create GitHub release and upload firmware |
| 50 | + - name: Auto increment release tag |
| 51 | + id: tag |
| 52 | + run: | |
| 53 | + latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") |
| 54 | + echo "Latest tag: $latest_tag" |
| 55 | + base=${latest_tag#v} |
| 56 | + IFS='.' read -r major minor patch <<< "$base" |
| 57 | + new_tag="v$major.$minor.$((patch+1))" |
| 58 | + echo "new_tag=$new_tag" >> $GITHUB_ENV |
| 59 | + echo "Next tag: $new_tag" |
| 60 | +
|
| 61 | + - name: Create GitHub Release |
51 | 62 | uses: softprops/action-gh-release@v2 |
52 | 63 | with: |
| 64 | + tag_name: ${{ env.new_tag }} |
| 65 | + name: "Auto Release ${{ env.new_tag }}" |
| 66 | + generate_release_notes: true |
53 | 67 | files: output/*.bin |
54 | 68 | env: |
55 | 69 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments