linux-appimage #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 从独立维护的 Linux 分支构建 x86_64 AppImage,并附加到已存在的共享 release。 | |
| # | |
| # linux-v1.4.0 映射到共享 release v1.4.0。构建源码和 workflow 都来自这个不可变的 | |
| # Linux tag,因此 Linux catalog、路径和 GTK 界面无需并入 macOS normal/main 分支。 | |
| name: linux-appimage | |
| on: | |
| push: | |
| tags: ['linux-v*'] | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: 'Existing shared release tag, for example v1.4.0' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write # 附加资产到 release 需要 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: swift:6.0-jammy | |
| steps: | |
| - name: Checkout tagged Linux source | |
| uses: actions/checkout@v4 | |
| - name: Map Linux tag to shared release tag | |
| id: release | |
| shell: bash | |
| run: | | |
| if [[ '${{ github.event_name }}' == 'workflow_dispatch' ]]; then | |
| release_tag='${{ inputs.release_tag }}' | |
| if [[ ! "$release_tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Unexpected shared release tag: $release_tag" >&2 | |
| exit 1 | |
| fi | |
| else | |
| linux_tag='${{ github.ref_name }}' | |
| if [[ ! "$linux_tag" =~ ^linux-(v[0-9].*)$ ]]; then | |
| echo "Unexpected Linux tag: $linux_tag" >&2 | |
| exit 1 | |
| fi | |
| release_tag="${BASH_REMATCH[1]}" | |
| fi | |
| echo "tag=$release_tag" >> "$GITHUB_OUTPUT" | |
| - name: Require an existing shared release | |
| uses: actions/github-script@v7 | |
| env: | |
| RELEASE_TAG: ${{ steps.release.outputs.tag }} | |
| with: | |
| script: | | |
| try { | |
| await github.rest.repos.getReleaseByTag({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag: process.env.RELEASE_TAG, | |
| }); | |
| } catch (error) { | |
| core.setFailed(`Shared release ${process.env.RELEASE_TAG} does not exist: ${error.message}`); | |
| } | |
| - name: Build AppImage | |
| run: | | |
| chmod +x scripts/build-appimage.sh | |
| ./scripts/build-appimage.sh | |
| - name: Attach AppImage + SHA256 to the release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.release.outputs.tag }} | |
| fail_on_unmatched_files: true | |
| files: | | |
| TokenClock-x86_64.AppImage | |
| TokenClock-x86_64.AppImage.sha256 |