|
| 1 | +name: Release Artifacts |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tag: |
| 9 | + description: 'Release tag to build for (e.g., 1.4.0)' |
| 10 | + required: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + # Build native riddlc binaries on each target platform |
| 14 | + native-build: |
| 15 | + timeout-minutes: 60 |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + packages: read |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - os: macos-latest |
| 24 | + artifact: riddlc-macos-arm64 |
| 25 | + arch: arm64 |
| 26 | + - os: macos-13 |
| 27 | + artifact: riddlc-macos-x86_64 |
| 28 | + arch: x86_64 |
| 29 | + - os: ubuntu-latest |
| 30 | + artifact: riddlc-linux-x86_64 |
| 31 | + arch: x86_64 |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + env: |
| 34 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + steps: |
| 36 | + - name: Checkout Code |
| 37 | + uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + ref: ${{ github.event.release.tag_name || github.event.inputs.tag }} |
| 40 | + |
| 41 | + - name: Set Up JDK 25 |
| 42 | + uses: actions/setup-java@v4 |
| 43 | + with: |
| 44 | + java-version: '25' |
| 45 | + distribution: temurin |
| 46 | + cache: sbt |
| 47 | + |
| 48 | + - name: Set Up SBT |
| 49 | + uses: sbt/setup-sbt@7e33f738678e47369c83dcb4b1d9c65d66eb3cdd # v1 |
| 50 | + |
| 51 | + - name: Coursier Caching |
| 52 | + uses: coursier/cache-action@2addd381bd2c931f42d4b734b9d0c9b73aac16fb # v6 |
| 53 | + |
| 54 | + - name: Configure sbt GitHub Packages credentials |
| 55 | + run: | |
| 56 | + mkdir -p ~/.sbt/1.0 |
| 57 | + cat > ~/.sbt/1.0/github.sbt << 'CREDSEOF' |
| 58 | + credentials += Credentials( |
| 59 | + "GitHub Package Registry", |
| 60 | + "maven.pkg.github.com", |
| 61 | + "x-access-token", |
| 62 | + sys.env.getOrElse("GITHUB_TOKEN", "") |
| 63 | + ) |
| 64 | + CREDSEOF |
| 65 | +
|
| 66 | + - name: Install LLVM and Clang (Linux only) |
| 67 | + if: runner.os == 'Linux' |
| 68 | + run: | |
| 69 | + sudo apt-get update && sudo apt-get install -y clang llvm |
| 70 | +
|
| 71 | + - name: Install curl dev dependencies (Linux only) |
| 72 | + if: runner.os == 'Linux' |
| 73 | + run: | |
| 74 | + sudo apt-get update |
| 75 | + sudo apt-get install -y libcurl4-openssl-dev libidn2-dev |
| 76 | +
|
| 77 | + - name: Build Native Binary |
| 78 | + run: sbt riddlcNative/nativeLink |
| 79 | + |
| 80 | + - name: Package Native Binary |
| 81 | + run: | |
| 82 | + mkdir -p staging/bin |
| 83 | + cp riddlc/native/target/scala-3.7.4/riddlc staging/bin/riddlc |
| 84 | + cd staging && zip -r ../${{ matrix.artifact }}.zip bin/ |
| 85 | +
|
| 86 | + - name: Upload to Release |
| 87 | + env: |
| 88 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + run: | |
| 90 | + TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}" |
| 91 | + gh release upload "$TAG" "${{ matrix.artifact }}.zip" --clobber |
| 92 | +
|
| 93 | + - name: Upload Build Artifact |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: ${{ matrix.artifact }} |
| 97 | + retention-days: 30 |
| 98 | + path: ${{ matrix.artifact }}.zip |
| 99 | + |
| 100 | + # Build JVM version (universal, runs on any platform with JDK) |
| 101 | + jvm-build: |
| 102 | + timeout-minutes: 60 |
| 103 | + permissions: |
| 104 | + contents: write |
| 105 | + packages: read |
| 106 | + runs-on: ubuntu-latest |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 109 | + steps: |
| 110 | + - name: Checkout Code |
| 111 | + uses: actions/checkout@v4 |
| 112 | + with: |
| 113 | + ref: ${{ github.event.release.tag_name || github.event.inputs.tag }} |
| 114 | + |
| 115 | + - name: Set Up JDK 25 |
| 116 | + uses: actions/setup-java@v4 |
| 117 | + with: |
| 118 | + java-version: '25' |
| 119 | + distribution: temurin |
| 120 | + cache: sbt |
| 121 | + |
| 122 | + - name: Set Up SBT |
| 123 | + uses: sbt/setup-sbt@7e33f738678e47369c83dcb4b1d9c65d66eb3cdd # v1 |
| 124 | + |
| 125 | + - name: Coursier Caching |
| 126 | + uses: coursier/cache-action@2addd381bd2c931f42d4b734b9d0c9b73aac16fb # v6 |
| 127 | + |
| 128 | + - name: Configure sbt GitHub Packages credentials |
| 129 | + run: | |
| 130 | + mkdir -p ~/.sbt/1.0 |
| 131 | + cat > ~/.sbt/1.0/github.sbt << 'CREDSEOF' |
| 132 | + credentials += Credentials( |
| 133 | + "GitHub Package Registry", |
| 134 | + "maven.pkg.github.com", |
| 135 | + "x-access-token", |
| 136 | + sys.env.getOrElse("GITHUB_TOKEN", "") |
| 137 | + ) |
| 138 | + CREDSEOF |
| 139 | +
|
| 140 | + - name: Build and Stage JVM Version |
| 141 | + run: | |
| 142 | + sbt riddlc/stage |
| 143 | + cd riddlc/jvm/target/universal/stage && zip -r ../../../../../riddlc.zip bin/ lib/ |
| 144 | +
|
| 145 | + - name: Upload to Release |
| 146 | + env: |
| 147 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 148 | + run: | |
| 149 | + TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}" |
| 150 | + gh release upload "$TAG" riddlc.zip --clobber |
| 151 | +
|
| 152 | + - name: Upload Build Artifact |
| 153 | + uses: actions/upload-artifact@v4 |
| 154 | + with: |
| 155 | + name: riddlc-jvm |
| 156 | + retention-days: 30 |
| 157 | + path: riddlc.zip |
| 158 | + |
| 159 | + # Update homebrew formula with new SHA256 hashes |
| 160 | + update-homebrew: |
| 161 | + needs: [native-build, jvm-build] |
| 162 | + timeout-minutes: 10 |
| 163 | + permissions: |
| 164 | + contents: write |
| 165 | + runs-on: ubuntu-latest |
| 166 | + env: |
| 167 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 168 | + steps: |
| 169 | + - name: Download all artifacts |
| 170 | + uses: actions/download-artifact@v4 |
| 171 | + with: |
| 172 | + path: artifacts |
| 173 | + |
| 174 | + - name: Compute SHA256 hashes |
| 175 | + id: hashes |
| 176 | + run: | |
| 177 | + echo "macos_arm64=$(shasum -a 256 artifacts/riddlc-macos-arm64/riddlc-macos-arm64.zip | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" |
| 178 | + echo "macos_x86=$(shasum -a 256 artifacts/riddlc-macos-x86_64/riddlc-macos-x86_64.zip | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" |
| 179 | + echo "linux_x86=$(shasum -a 256 artifacts/riddlc-linux-x86_64/riddlc-linux-x86_64.zip | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" |
| 180 | + echo "jvm=$(shasum -a 256 artifacts/riddlc-jvm/riddlc.zip | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" |
| 181 | +
|
| 182 | + - name: Checkout homebrew-tap |
| 183 | + uses: actions/checkout@v4 |
| 184 | + with: |
| 185 | + repository: ossuminc/homebrew-tap |
| 186 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 187 | + path: homebrew-tap |
| 188 | + |
| 189 | + - name: Update formula |
| 190 | + env: |
| 191 | + TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }} |
| 192 | + SHA_MACOS_ARM64: ${{ steps.hashes.outputs.macos_arm64 }} |
| 193 | + SHA_MACOS_X86: ${{ steps.hashes.outputs.macos_x86 }} |
| 194 | + SHA_LINUX_X86: ${{ steps.hashes.outputs.linux_x86 }} |
| 195 | + SHA_JVM: ${{ steps.hashes.outputs.jvm }} |
| 196 | + run: | |
| 197 | + cat > homebrew-tap/Formula/riddlc.rb << FORMULA |
| 198 | + # Homebrew formula for riddlc - the RIDDL compiler |
| 199 | + # To install: brew install ossuminc/tap/riddlc |
| 200 | + # Or add the tap first: brew tap ossuminc/tap && brew install riddlc |
| 201 | + # Auto-generated by release.yml - do not edit manually |
| 202 | +
|
| 203 | + class Riddlc < Formula |
| 204 | + desc "Compiler for RIDDL (Reactive Interface to Domain Definition Language)" |
| 205 | + homepage "https://github.com/ossuminc/riddl" |
| 206 | + version "${TAG}" |
| 207 | + license "Apache-2.0" |
| 208 | +
|
| 209 | + if OS.mac? && Hardware::CPU.arm? |
| 210 | + url "https://github.com/ossuminc/riddl/releases/download/#{version}/riddlc-macos-arm64.zip" |
| 211 | + sha256 "${SHA_MACOS_ARM64}" |
| 212 | + elsif OS.mac? && Hardware::CPU.intel? |
| 213 | + url "https://github.com/ossuminc/riddl/releases/download/#{version}/riddlc-macos-x86_64.zip" |
| 214 | + sha256 "${SHA_MACOS_X86}" |
| 215 | + elsif OS.linux? |
| 216 | + url "https://github.com/ossuminc/riddl/releases/download/#{version}/riddlc-linux-x86_64.zip" |
| 217 | + sha256 "${SHA_LINUX_X86}" |
| 218 | + else |
| 219 | + url "https://github.com/ossuminc/riddl/releases/download/#{version}/riddlc.zip" |
| 220 | + sha256 "${SHA_JVM}" |
| 221 | + depends_on "openjdk@21" |
| 222 | + end |
| 223 | +
|
| 224 | + def install |
| 225 | + if OS.mac? || OS.linux? |
| 226 | + if !Hardware::CPU.type.to_s.start_with?("arm") || !OS.mac? |
| 227 | + # x86_64 native or Linux native |
| 228 | + bin.install "bin/riddlc" |
| 229 | + else |
| 230 | + # macOS ARM64 native |
| 231 | + bin.install "bin/riddlc" |
| 232 | + end |
| 233 | + else |
| 234 | + # JVM fallback |
| 235 | + rm "bin/riddlc.bat" |
| 236 | + libexec.install "lib" |
| 237 | + libexec.install "bin" |
| 238 | + (bin/"riddlc").write <<~EOS |
| 239 | + #!/bin/bash |
| 240 | + export JAVA_HOME="#{Formula["openjdk@21"].opt_prefix}" |
| 241 | + exec "#{libexec}/bin/riddlc" "$@" |
| 242 | + EOS |
| 243 | + end |
| 244 | + end |
| 245 | +
|
| 246 | + def caveats |
| 247 | + if OS.mac? || OS.linux? |
| 248 | + <<~EOS |
| 249 | + riddlc is installed as a native binary. No JDK required. |
| 250 | +
|
| 251 | + To verify the installation: |
| 252 | + riddlc version |
| 253 | +
|
| 254 | + For help: |
| 255 | + riddlc help |
| 256 | + EOS |
| 257 | + else |
| 258 | + <<~EOS |
| 259 | + riddlc requires Java 21. This formula uses openjdk@21. |
| 260 | +
|
| 261 | + To verify the installation: |
| 262 | + riddlc version |
| 263 | +
|
| 264 | + For help: |
| 265 | + riddlc help |
| 266 | + EOS |
| 267 | + end |
| 268 | + end |
| 269 | +
|
| 270 | + test do |
| 271 | + assert_match "riddlc version", shell_output("#{bin}/riddlc version") |
| 272 | + end |
| 273 | + end |
| 274 | + FORMULA |
| 275 | +
|
| 276 | + - name: Commit and push formula |
| 277 | + run: | |
| 278 | + cd homebrew-tap |
| 279 | + git config user.name "github-actions[bot]" |
| 280 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 281 | + TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}" |
| 282 | + git add Formula/riddlc.rb |
| 283 | + git diff --cached --quiet || git commit -m "Update riddlc to ${TAG} with multi-platform native binaries" |
| 284 | + git push |
0 commit comments