|
| 1 | +name: Release CLI |
| 2 | + |
| 3 | +# Cross-build the `ada` CLI for the supported targets, bundle each binary |
| 4 | +# with the `radius/` artifact tree (recipes, resource types, env bicep, |
| 5 | +# bicepconfig), and attach the archives to a GitHub Release. |
| 6 | +# |
| 7 | +# Triggers: |
| 8 | +# * push of a tag matching `cli-v*` — publishes the release. |
| 9 | +# * manual `workflow_dispatch` with an explicit tag — useful for dry |
| 10 | +# runs against a feature branch. |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + tags: |
| 15 | + - 'cli-v*' |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + tag: |
| 19 | + description: 'Release tag to publish (e.g. cli-v0.1.0)' |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: write |
| 25 | + |
| 26 | +jobs: |
| 27 | + build: |
| 28 | + name: build ${{ matrix.target }} |
| 29 | + runs-on: ${{ matrix.runner }} |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + include: |
| 34 | + - target: x86_64-unknown-linux-gnu |
| 35 | + runner: ubuntu-latest |
| 36 | + archive: tar.gz |
| 37 | + - target: aarch64-unknown-linux-gnu |
| 38 | + runner: ubuntu-latest |
| 39 | + archive: tar.gz |
| 40 | + # Cross-compile to arm64 from x64 linux. Avoids spinning up an |
| 41 | + # arm64 runner just for this binary. |
| 42 | + cross: true |
| 43 | + - target: x86_64-apple-darwin |
| 44 | + runner: macos-13 |
| 45 | + archive: tar.gz |
| 46 | + - target: aarch64-apple-darwin |
| 47 | + runner: macos-14 |
| 48 | + archive: tar.gz |
| 49 | + - target: x86_64-pc-windows-msvc |
| 50 | + runner: windows-latest |
| 51 | + archive: zip |
| 52 | + ext: .exe |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Resolve tag |
| 58 | + id: tag |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + set -euo pipefail |
| 62 | + if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then |
| 63 | + tag='${{ inputs.tag }}' |
| 64 | + else |
| 65 | + tag='${{ github.ref_name }}' |
| 66 | + fi |
| 67 | + if [[ ! "$tag" =~ ^cli-v ]]; then |
| 68 | + echo "::error::tag '$tag' must start with cli-v" >&2 |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 72 | + echo "version=${tag#cli-v}" >> "$GITHUB_OUTPUT" |
| 73 | +
|
| 74 | + - name: Install Rust toolchain |
| 75 | + uses: dtolnay/rust-toolchain@stable |
| 76 | + with: |
| 77 | + targets: ${{ matrix.target }} |
| 78 | + |
| 79 | + - name: Install cross-compile linker (linux arm64) |
| 80 | + if: matrix.cross == true |
| 81 | + run: | |
| 82 | + sudo apt-get update |
| 83 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 84 | + mkdir -p ~/.cargo |
| 85 | + cat >> ~/.cargo/config.toml <<'EOF' |
| 86 | + [target.aarch64-unknown-linux-gnu] |
| 87 | + linker = "aarch64-linux-gnu-gcc" |
| 88 | + EOF |
| 89 | +
|
| 90 | + - name: Build |
| 91 | + working-directory: cli |
| 92 | + run: cargo build --release --locked --target ${{ matrix.target }} |
| 93 | + |
| 94 | + - name: Stage release tree |
| 95 | + id: stage |
| 96 | + shell: bash |
| 97 | + run: | |
| 98 | + set -euo pipefail |
| 99 | + version='${{ steps.tag.outputs.version }}' |
| 100 | + target='${{ matrix.target }}' |
| 101 | + stage="dist/ada-${version}-${target}" |
| 102 | + ext='${{ matrix.ext }}' |
| 103 | + mkdir -p "${stage}/bin" "${stage}/radius" |
| 104 | + cp "cli/target/${target}/release/ada${ext}" "${stage}/bin/ada${ext}" |
| 105 | + # Bundle the Radius asset tree as-is so install scripts can |
| 106 | + # drop it under $ADA_HOME/radius without any rewriting. |
| 107 | + cp -R radius/. "${stage}/radius/" |
| 108 | + cp cli/README.md "${stage}/README.md" || true |
| 109 | + cp LICENSE "${stage}/LICENSE" || true |
| 110 | + echo "stage=${stage}" >> "$GITHUB_OUTPUT" |
| 111 | + echo "name=ada-${version}-${target}" >> "$GITHUB_OUTPUT" |
| 112 | +
|
| 113 | + - name: Pack tar.gz |
| 114 | + if: matrix.archive == 'tar.gz' |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + set -euo pipefail |
| 118 | + (cd dist && tar -czf "${{ steps.stage.outputs.name }}.tar.gz" "${{ steps.stage.outputs.name }}") |
| 119 | + (cd dist && shasum -a 256 "${{ steps.stage.outputs.name }}.tar.gz" > "${{ steps.stage.outputs.name }}.tar.gz.sha256") |
| 120 | +
|
| 121 | + - name: Pack zip |
| 122 | + if: matrix.archive == 'zip' |
| 123 | + shell: pwsh |
| 124 | + run: | |
| 125 | + $name = '${{ steps.stage.outputs.name }}' |
| 126 | + Push-Location dist |
| 127 | + Compress-Archive -Path $name -DestinationPath "$name.zip" -Force |
| 128 | + $hash = Get-FileHash -Algorithm SHA256 "$name.zip" |
| 129 | + "$($hash.Hash.ToLower()) $name.zip" | Out-File -Encoding ascii "$name.zip.sha256" |
| 130 | + Pop-Location |
| 131 | +
|
| 132 | + - name: Upload artifact |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: ${{ steps.stage.outputs.name }} |
| 136 | + path: | |
| 137 | + dist/${{ steps.stage.outputs.name }}.tar.gz |
| 138 | + dist/${{ steps.stage.outputs.name }}.tar.gz.sha256 |
| 139 | + dist/${{ steps.stage.outputs.name }}.zip |
| 140 | + dist/${{ steps.stage.outputs.name }}.zip.sha256 |
| 141 | + if-no-files-found: ignore |
| 142 | + |
| 143 | + release: |
| 144 | + name: publish release |
| 145 | + needs: build |
| 146 | + runs-on: ubuntu-latest |
| 147 | + steps: |
| 148 | + - name: Checkout |
| 149 | + uses: actions/checkout@v4 |
| 150 | + |
| 151 | + - name: Resolve tag |
| 152 | + id: tag |
| 153 | + shell: bash |
| 154 | + run: | |
| 155 | + set -euo pipefail |
| 156 | + if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then |
| 157 | + tag='${{ inputs.tag }}' |
| 158 | + else |
| 159 | + tag='${{ github.ref_name }}' |
| 160 | + fi |
| 161 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 162 | + echo "version=${tag#cli-v}" >> "$GITHUB_OUTPUT" |
| 163 | +
|
| 164 | + - name: Download all artifacts |
| 165 | + uses: actions/download-artifact@v4 |
| 166 | + with: |
| 167 | + path: dist |
| 168 | + merge-multiple: true |
| 169 | + |
| 170 | + - name: List staged assets |
| 171 | + run: ls -lah dist |
| 172 | + |
| 173 | + - name: Publish GitHub Release |
| 174 | + uses: ncipollo/release-action@v1 |
| 175 | + with: |
| 176 | + allowUpdates: true |
| 177 | + artifactErrorsFailBuild: true |
| 178 | + tag: ${{ steps.tag.outputs.tag }} |
| 179 | + name: ada ${{ steps.tag.outputs.version }} |
| 180 | + artifacts: 'dist/*.tar.gz,dist/*.tar.gz.sha256,dist/*.zip,dist/*.zip.sha256' |
| 181 | + body: | |
| 182 | + Adaptive Apps CLI **${{ steps.tag.outputs.version }}**. |
| 183 | +
|
| 184 | + Each archive contains the `ada` binary plus the full Radius asset |
| 185 | + tree (`recipes/`, `resource-types/`, `*.bicep`, `bicepconfig.json`, |
| 186 | + `types.tgz`). Use the one-line installers to drop it under |
| 187 | + `~/.adaptive`: |
| 188 | +
|
| 189 | + ```bash |
| 190 | + # macOS / Linux |
| 191 | + curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/cli/install.sh | bash |
| 192 | + ``` |
| 193 | +
|
| 194 | + ```powershell |
| 195 | + # Windows PowerShell |
| 196 | + iwr -useb https://raw.githubusercontent.com/${{ github.repository }}/main/cli/install.ps1 | iex |
| 197 | + ``` |
| 198 | +
|
| 199 | + Override the install root with `ADA_HOME=/custom/path` (or |
| 200 | + `-AdaHome` on Windows). Pin a version with |
| 201 | + `ADA_VERSION=${{ steps.tag.outputs.tag }}`. |
0 commit comments