|
| 1 | +name: Desktop Release |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + |
| 11 | +env: |
| 12 | + RELEASE_ALLOWED_OWNER: 1Blademaster |
| 13 | + RELEASE_ALLOWED_ACTOR: 1Blademaster |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: release-${{ github.ref }} |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + authorize: |
| 21 | + name: Authorize Release Actor |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Validate release owner and actor |
| 25 | + shell: bash |
| 26 | + run: | |
| 27 | + if [[ "${GITHUB_REPOSITORY_OWNER}" != "${RELEASE_ALLOWED_OWNER}" ]]; then |
| 28 | + echo "Release blocked: repository owner '${GITHUB_REPOSITORY_OWNER}' is not '${RELEASE_ALLOWED_OWNER}'." |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | +
|
| 32 | + if [[ "${GITHUB_ACTOR}" != "${RELEASE_ALLOWED_ACTOR}" ]]; then |
| 33 | + echo "Release blocked: actor '${GITHUB_ACTOR}' is not '${RELEASE_ALLOWED_ACTOR}'." |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | +
|
| 37 | + echo "Release authorized for ${GITHUB_ACTOR} on ${GITHUB_REPOSITORY}." |
| 38 | +
|
| 39 | + prepare: |
| 40 | + name: Prepare Release Metadata |
| 41 | + needs: authorize |
| 42 | + runs-on: ubuntu-latest |
| 43 | + outputs: |
| 44 | + tag: ${{ steps.meta.outputs.tag }} |
| 45 | + version: ${{ steps.meta.outputs.version }} |
| 46 | + prerelease: ${{ steps.meta.outputs.prerelease }} |
| 47 | + steps: |
| 48 | + - name: Validate tag and extract version |
| 49 | + id: meta |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + TAG="${GITHUB_REF_NAME}" |
| 53 | + VERSION="${TAG#v}" |
| 54 | +
|
| 55 | + if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then |
| 56 | + echo "Invalid release tag: $TAG" |
| 57 | + echo "Expected format: vX.Y.Z or vX.Y.Z-suffix" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + PRERELEASE="false" |
| 62 | + # if [[ "$VERSION" == *-* ]] || [[ "$VERSION" == *alpha* ]] || [[ "$VERSION" == *beta* ]] || [[ "$VERSION" == *rc* ]]; then |
| 63 | + # PRERELEASE="true" |
| 64 | + # fi |
| 65 | +
|
| 66 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 67 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 68 | + echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT" |
| 69 | +
|
| 70 | + - name: Create draft release |
| 71 | + uses: softprops/action-gh-release@v3 |
| 72 | + with: |
| 73 | + tag_name: ${{ steps.meta.outputs.tag }} |
| 74 | + name: FGCS ${{ steps.meta.outputs.tag }} |
| 75 | + draft: true |
| 76 | + prerelease: ${{ steps.meta.outputs.prerelease == 'true' }} |
| 77 | + generate_release_notes: true |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + |
| 81 | + build: |
| 82 | + name: Build ${{ matrix.name }} |
| 83 | + needs: prepare |
| 84 | + runs-on: ${{ matrix.os }} |
| 85 | + strategy: |
| 86 | + fail-fast: false |
| 87 | + matrix: |
| 88 | + include: |
| 89 | + - name: Windows x64 |
| 90 | + os: windows-latest |
| 91 | + platform: windows |
| 92 | + arch: x64 |
| 93 | + - name: macOS x64 |
| 94 | + os: macos-13 |
| 95 | + platform: mac |
| 96 | + arch: x64 |
| 97 | + - name: macOS arm64 |
| 98 | + os: macos-latest |
| 99 | + platform: mac |
| 100 | + arch: arm64 |
| 101 | + env: |
| 102 | + VERSION: ${{ needs.prepare.outputs.version }} |
| 103 | + RELEASE_TAG: ${{ needs.prepare.outputs.tag }} |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Check out Git repository |
| 107 | + uses: actions/checkout@v6 |
| 108 | + |
| 109 | + - name: Set up Node.js |
| 110 | + uses: actions/setup-node@v6 |
| 111 | + with: |
| 112 | + node-version: 22 |
| 113 | + |
| 114 | + - name: Set up Python 3.11 |
| 115 | + uses: actions/setup-python@v5 |
| 116 | + with: |
| 117 | + python-version: '3.11' |
| 118 | + |
| 119 | + - name: Build on Windows |
| 120 | + if: matrix.platform == 'windows' |
| 121 | + shell: pwsh |
| 122 | + working-directory: building/windows |
| 123 | + run: | |
| 124 | + python -m venv radio\venv |
| 125 | + .\radio\venv\Scripts\Activate.ps1 |
| 126 | + python -m pip install --upgrade pip |
| 127 | + pip install -r radio\requirements.txt |
| 128 | + .\building\windows\build.ps1 -Version "$env:VERSION" -Arch "${{ matrix.arch }}" |
| 129 | +
|
| 130 | + - name: Build on macOS |
| 131 | + if: matrix.platform == 'mac' |
| 132 | + shell: bash |
| 133 | + working-directory: building/macos |
| 134 | + run: | |
| 135 | + python3 -m venv radio/venv |
| 136 | + source radio/venv/bin/activate |
| 137 | + python3 -m pip install --upgrade pip |
| 138 | + pip install -r radio/requirements.txt |
| 139 | + chmod +x building/macos/build.sh |
| 140 | + ./building/macos/build.sh "$VERSION" "${{ matrix.arch }}" |
| 141 | +
|
| 142 | + - name: Upload Windows installer |
| 143 | + if: matrix.platform == 'windows' |
| 144 | + uses: softprops/action-gh-release@v3 |
| 145 | + with: |
| 146 | + tag_name: ${{ env.RELEASE_TAG }} |
| 147 | + draft: true |
| 148 | + files: | |
| 149 | + gcs/release/${{ env.VERSION }}/FGCS-Windows-${{ env.VERSION }}-Setup.exe |
| 150 | + env: |
| 151 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 152 | + |
| 153 | + - name: Upload macOS installer |
| 154 | + if: matrix.platform == 'mac' |
| 155 | + uses: softprops/action-gh-release@v3 |
| 156 | + with: |
| 157 | + tag_name: ${{ env.RELEASE_TAG }} |
| 158 | + draft: true |
| 159 | + files: | |
| 160 | + gcs/release/${{ env.VERSION }}/FGCS-Mac-${{ env.VERSION }}-Installer-${{ matrix.arch }}.dmg |
| 161 | + env: |
| 162 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments