|
| 1 | +name: Release On-Demand |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build-and-release: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + |
| 18 | + - name: Setup Node.js |
| 19 | + uses: actions/setup-node@v4 |
| 20 | + with: |
| 21 | + node-version: '20' |
| 22 | + |
| 23 | + - name: Extract Version |
| 24 | + id: version |
| 25 | + run: | |
| 26 | + VERSION=$(grep '#define MENU_VERSION' include/pldmgr.h | awk '{print $3}' | tr -d '"' | tr -d '\r') |
| 27 | + if [ -z "$VERSION" ]; then |
| 28 | + echo "Error: Could not find MENU_VERSION in include/pldmgr.h" |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | + echo "Extracted version: $VERSION" |
| 32 | + echo "tag=v${VERSION}" >> $GITHUB_OUTPUT |
| 33 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 34 | +
|
| 35 | + - name: Check if release exists |
| 36 | + env: |
| 37 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + run: | |
| 39 | + TAG="${{ steps.version.outputs.tag }}" |
| 40 | + if gh release view "$TAG" >/dev/null 2>&1; then |
| 41 | + echo "Release $TAG already exists. Aborting." |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + echo "Release $TAG does not exist. Proceeding." |
| 45 | +
|
| 46 | + - name: Build Payload Manager |
| 47 | + run: | |
| 48 | + chmod +x build_release.sh |
| 49 | + ./build_release.sh |
| 50 | +
|
| 51 | + - name: Create Release |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + run: | |
| 55 | + TAG="${{ steps.version.outputs.tag }}" |
| 56 | + VERSION="${{ steps.version.outputs.version }}" |
| 57 | + # Get the most recent tag before this release to generate the changelog link |
| 58 | + PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
| 59 | + |
| 60 | + if [ -n "$PREV_TAG" ]; then |
| 61 | + NOTES="Full Changelog: https://github.com/${{ github.repository }}/compare/$PREV_TAG...$TAG" |
| 62 | + else |
| 63 | + NOTES="First Release." |
| 64 | + fi |
| 65 | + |
| 66 | + # Create the release and upload the ELF file |
| 67 | + gh release create "$TAG" \ |
| 68 | + --title "$TAG" \ |
| 69 | + --notes "$NOTES" \ |
| 70 | + "pldmgr_v${VERSION}.elf" |
0 commit comments