release-only downloads, autocomplete #43
Workflow file for this run
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
| name: release | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: Existing git tag to publish | |
| required: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| release_tag: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| value: ${{ steps.tag.outputs.value }} | |
| steps: | |
| - name: Resolve release tag | |
| id: tag | |
| env: | |
| INPUT_TAG: ${{ github.event.inputs.tag }} | |
| run: | | |
| if [ -n "${INPUT_TAG}" ]; then | |
| RELEASE_TAG="${INPUT_TAG}" | |
| else | |
| RELEASE_TAG="${GITHUB_REF_NAME}" | |
| fi | |
| if ! [[ "${RELEASE_TAG}" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then | |
| echo "Invalid release tag: ${RELEASE_TAG}" >&2 | |
| echo "Release tags may only contain letters, numbers, '.', '_', and '-'." >&2 | |
| exit 1 | |
| fi | |
| printf 'value=%s\n' "${RELEASE_TAG}" >> "${GITHUB_OUTPUT}" | |
| integration_preflight: | |
| needs: release_tag | |
| uses: ./.github/workflows/integration-full.yml | |
| secrets: inherit | |
| with: | |
| release_preflight: true | |
| build: | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - release_tag | |
| - integration_preflight | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - x64 | |
| - arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build Terrarium binary | |
| env: | |
| TERRARIUM_VERSION: ${{ needs.release_tag.outputs.value }} | |
| run: | | |
| mkdir -p release/dist | |
| bun scripts/build.ts | |
| bun build --compile --target=bun-linux-${{ matrix.arch }} scripts/terrariumctl.ts --outfile release/dist/terrariumctl | |
| - name: Package release bundle | |
| run: | | |
| cp -a ansible release/ansible | |
| rm -rf release/ansible/.ansible | |
| cd release | |
| zip -rq "../terrarium-linux-${{ matrix.arch }}.zip" dist ansible | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: terrarium-linux-${{ matrix.arch }} | |
| path: terrarium-linux-${{ matrix.arch }}.zip | |
| if-no-files-found: error | |
| publish: | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - release_tag | |
| - build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release assets | |
| env: | |
| RELEASE_TAG: ${{ needs.release_tag.outputs.value }} | |
| run: | | |
| mkdir -p release-assets | |
| cp artifacts/terrarium-linux-x64/terrarium-linux-x64.zip release-assets/ | |
| cp artifacts/terrarium-linux-arm64/terrarium-linux-arm64.zip release-assets/ | |
| python3 - <<'PY' | |
| from pathlib import Path | |
| import os | |
| import shlex | |
| release_tag = os.environ["RELEASE_TAG"] | |
| source = Path("install.sh").read_text() | |
| needle = 'EMBEDDED_BOOTSTRAP_REF="" # TERRARIUM_RELEASE_REF' | |
| replacement = f"EMBEDDED_BOOTSTRAP_REF={shlex.quote(release_tag)} # TERRARIUM_RELEASE_REF" | |
| if needle not in source: | |
| raise SystemExit("install.sh release placeholder not found") | |
| Path("release-assets/install.sh").write_text(source.replace(needle, replacement, 1)) | |
| PY | |
| chmod 0644 release-assets/install.sh | |
| ( | |
| cd release-assets | |
| sha256sum terrarium-linux-x64.zip terrarium-linux-arm64.zip install.sh > SHA256SUMS | |
| ) | |
| - name: Publish GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.release_tag.outputs.value }} | |
| files: | | |
| release-assets/install.sh | |
| release-assets/terrarium-linux-x64.zip | |
| release-assets/terrarium-linux-arm64.zip | |
| release-assets/SHA256SUMS | |
| generate_release_notes: true | |
| prerelease: ${{ contains(needs.release_tag.outputs.value, '-') }} |