|
| 1 | +name: Binary Release |
| 2 | + |
| 3 | +# Trigger AFTER the Maven release has created a tag and GitHub release |
| 4 | +# This workflow adds native binaries to the existing release |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: 'Version tag to attach binaries to (e.g., 0.34.0)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + dry_run: |
| 13 | + description: 'Dry run: build binaries but skip release/publishing' |
| 14 | + required: false |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + push: |
| 18 | + tags: |
| 19 | + - '[0-9]+.[0-9]+.[0-9]+' |
| 20 | + |
| 21 | +env: |
| 22 | + GRAAL_VERSION: '25' |
| 23 | + JAVA_VERSION: '25' |
| 24 | + |
| 25 | +jobs: |
| 26 | + # Build native binaries for each platform |
| 27 | + build: |
| 28 | + name: Build ${{ matrix.platform }}-${{ matrix.arch }} |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + # macOS Intel |
| 34 | + - os: macos-13 |
| 35 | + platform: darwin |
| 36 | + arch: x86_64 |
| 37 | + artifact-suffix: darwin-x86_64 |
| 38 | + |
| 39 | + # macOS Apple Silicon |
| 40 | + - os: macos-latest |
| 41 | + platform: darwin |
| 42 | + arch: aarch64 |
| 43 | + artifact-suffix: darwin-aarch64 |
| 44 | + |
| 45 | + # Linux x86_64 |
| 46 | + - os: ubuntu-latest |
| 47 | + platform: linux |
| 48 | + arch: x86_64 |
| 49 | + artifact-suffix: linux-x86_64 |
| 50 | + |
| 51 | + # Linux ARM64 (via Docker) |
| 52 | + - os: ubuntu-latest |
| 53 | + platform: linux |
| 54 | + arch: aarch64 |
| 55 | + artifact-suffix: linux-aarch64 |
| 56 | + use-docker: true |
| 57 | + |
| 58 | + # Windows x86_64 |
| 59 | + - os: windows-latest |
| 60 | + platform: windows |
| 61 | + arch: x86_64 |
| 62 | + artifact-suffix: windows-x86_64 |
| 63 | + |
| 64 | + runs-on: ${{ matrix.os }} |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + fetch-depth: 0 |
| 71 | + |
| 72 | + - name: Set up GraalVM |
| 73 | + if: ${{ !matrix.use-docker }} |
| 74 | + uses: graalvm/setup-graalvm@v1 |
| 75 | + with: |
| 76 | + java-version: ${{ env.JAVA_VERSION }} |
| 77 | + distribution: 'graalvm' |
| 78 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + native-image-job-reports: 'true' |
| 80 | + |
| 81 | + - name: Build Native Binary (Linux ARM64 via Docker) |
| 82 | + if: matrix.use-docker && matrix.arch == 'aarch64' |
| 83 | + run: | |
| 84 | + docker run --rm \ |
| 85 | + -v "${{ github.workspace }}:/workspace" \ |
| 86 | + -w /workspace/jmolecules-cli \ |
| 87 | + --platform linux/arm64 \ |
| 88 | + ghcr.io/graalvm/graalvm-community:25 \ |
| 89 | + sh -c "../mvnw -B -Pdist clean package" |
| 90 | +
|
| 91 | + - name: Build Native Binary (Standard) |
| 92 | + if: ${{ !matrix.use-docker }} |
| 93 | + working-directory: jmolecules-cli |
| 94 | + run: ../mvnw -B -Pdist clean package |
| 95 | + |
| 96 | + - name: Create Archive (Unix) |
| 97 | + if: matrix.platform != 'windows' |
| 98 | + working-directory: jmolecules-cli/target |
| 99 | + run: | |
| 100 | + mkdir -p distributions |
| 101 | + tar -czf distributions/jm-${{ github.event.inputs.version || github.ref_name }}-${{ matrix.artifact-suffix }}.tar.gz \ |
| 102 | + -C .. target/jm \ |
| 103 | + -C .. target/jm.completion |
| 104 | +
|
| 105 | + - name: Create Archive (Windows) |
| 106 | + if: matrix.platform == 'windows' |
| 107 | + working-directory: jmolecules-cli/target |
| 108 | + shell: pwsh |
| 109 | + run: | |
| 110 | + New-Item -ItemType Directory -Force -Path distributions |
| 111 | + Compress-Archive -Path jm.exe,jm.completion -DestinationPath distributions/jm-${{ github.event.inputs.version || github.ref_name }}-${{ matrix.artifact-suffix }}.zip |
| 112 | +
|
| 113 | + - name: Upload Artifact |
| 114 | + uses: actions/upload-artifact@v4 |
| 115 | + with: |
| 116 | + name: jm-${{ matrix.artifact-suffix }} |
| 117 | + path: jmolecules-cli/target/distributions/* |
| 118 | + retention-days: ${{ github.event.inputs.dry_run == 'true' && 7 || 1 }} |
| 119 | + |
| 120 | + # Attach binaries to existing release using jReleaser |
| 121 | + release: |
| 122 | + name: Attach Binaries to Release |
| 123 | + needs: [build] |
| 124 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
| 125 | + runs-on: ubuntu-latest |
| 126 | + |
| 127 | + steps: |
| 128 | + - name: Checkout |
| 129 | + uses: actions/checkout@v4 |
| 130 | + with: |
| 131 | + fetch-depth: 0 |
| 132 | + |
| 133 | + - name: Download all artifacts |
| 134 | + uses: actions/download-artifact@v4 |
| 135 | + with: |
| 136 | + path: jmolecules-cli/target/distributions |
| 137 | + merge-multiple: true |
| 138 | + |
| 139 | + - name: Set up Java |
| 140 | + uses: actions/setup-java@v4 |
| 141 | + with: |
| 142 | + java-version: ${{ env.JAVA_VERSION }} |
| 143 | + distribution: 'temurin' |
| 144 | + |
| 145 | + - name: Run JReleaser (Update Release) |
| 146 | + uses: jreleaser/release-action@v2 |
| 147 | + with: |
| 148 | + version: latest |
| 149 | + arguments: full-release |
| 150 | + working-directory: jmolecules-cli |
| 151 | + env: |
| 152 | + JRELEASER_PROJECT_VERSION: ${{ github.event.inputs.version || github.ref_name }} |
| 153 | + JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }} |
| 154 | + |
| 155 | + - name: JReleaser Output |
| 156 | + if: always() |
| 157 | + uses: actions/upload-artifact@v4 |
| 158 | + with: |
| 159 | + name: jreleaser-logs |
| 160 | + path: | |
| 161 | + jmolecules-cli/out/jreleaser/trace.log |
| 162 | + jmolecules-cli/out/jreleaser/output.properties |
0 commit comments