|
| 1 | +name: create-release-mac |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Optional tag (starts with `v`). Default to the tag of the selected branch.' |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + runs-on: windows-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} |
| 27 | + - uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + distribution: temurin |
| 30 | + java-version: '21' |
| 31 | + cache: 'gradle' |
| 32 | + - uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: '22' |
| 35 | + - name: Setup Gradle |
| 36 | + uses: gradle/actions/setup-gradle@v3 |
| 37 | + with: |
| 38 | + cache-read-only: ${{ github.ref != 'refs/heads/main' }} |
| 39 | + - name: Get version |
| 40 | + id: version |
| 41 | + run: echo "VERSION=$(./gradlew -q printInternalVersion)" >> "$GITHUB_OUTPUT" |
| 42 | + - name: Validate the tag name |
| 43 | + run: | |
| 44 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ ! -z "${{ github.event.inputs.tag }}" ]; then |
| 45 | + TAG=${{ github.event.inputs.tag }} |
| 46 | + else |
| 47 | + TAG=${GITHUB_REF#refs/tags/} |
| 48 | + fi |
| 49 | + if [[ ! "$TAG" =~ ^v ]]; then |
| 50 | + echo "Error: Tag ($TAG) must start with 'v'" |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | + if [[ ! $TAG == v${{ steps.version.outputs.VERSION }} ]]; then |
| 54 | + echo "Error: Git tag version ($TAG) doesn't match project version (v${{ steps.version.outputs.VERSION }})" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + - name: Install Node modules |
| 58 | + run: npm install |
| 59 | + - name: Download CodeSignTool and extract |
| 60 | + run: | |
| 61 | + $ProgressPreference = 'SilentlyContinue' |
| 62 | + New-Item -ItemType Directory -Force -Path "./build-tools/codesign" |
| 63 | + Invoke-WebRequest -Uri "https://www.ssl.com/download/codesigntool-for-windows/" -OutFile "./build-tools/CodeSignTool.zip" |
| 64 | + Expand-Archive -Path "./build-tools/CodeSignTool.zip" -DestinationPath "./build-tools/codesign" -Force |
| 65 | + Remove-Item "./build-tools/CodeSignTool.zip" |
| 66 | + shell: pwsh |
| 67 | + - name: Download wixtool 3 and extract |
| 68 | + run: | |
| 69 | + $ProgressPreference = 'SilentlyContinue' |
| 70 | + New-Item -ItemType Directory -Force -Path "./build-tools/wixtool" |
| 71 | + Invoke-WebRequest -Uri "https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip" -OutFile "./build-tools/wix-binaries.zip" |
| 72 | + Expand-Archive -Path "./build-tools/wix-binaries.zip" -DestinationPath "./build-tools/wixtool" -Force |
| 73 | + Remove-Item "./build-tools/wix-binaries.zip" |
| 74 | + shell: pwsh |
| 75 | + - name: Build an MSI |
| 76 | + run: | |
| 77 | + export PATH="$PATH:$PWD/build-tools/wixtool" |
| 78 | + ./gradlew clean jpackage |
| 79 | + env: |
| 80 | + CODESIGN_TOOL_DIR: "./build-tools/codesign" |
| 81 | + SSL_COM_USERNAME: ${{ secrets.SSL_COM_USERNAME }} |
| 82 | + SSL_COM_PASSWORD: ${{ secrets.SSL_COM_PASSWORD }} |
| 83 | + SSL_COM_TOTP_SECRET: ${{ secrets.SSL_COM_TOTP_SECRET }} |
| 84 | + - name: Upload Release Asset |
| 85 | + uses: softprops/action-gh-release@v2 |
| 86 | + with: |
| 87 | + draft: true |
| 88 | + prerelease: true |
| 89 | + files: ./build/msi/*.msi |
| 90 | + overwrite_files: true |
| 91 | + fail_on_unmatched_files: true |
| 92 | + generate_release_notes: true |
| 93 | + tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} |
0 commit comments