feat(sql): add 0.4.0-main migration #308
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: Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - '[0-9]+.*' | |
| pull_request: | |
| jobs: | |
| validate-release-versions: | |
| name: Validate Release Versions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Validate SDK package versions against tag | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ "${GITHUB_REF}" != refs/tags/* ]]; then | |
| echo "Not a tag build; skipping release version validation." | |
| exit 0 | |
| fi | |
| tag="${GITHUB_REF#refs/tags/}" | |
| python3 - <<'PY' "$tag" | |
| import json | |
| import pathlib | |
| import sys | |
| import tomllib | |
| tag = sys.argv[1] | |
| root = pathlib.Path('.') | |
| ts_version = json.loads((root / 'sdks/typescript/package.json').read_text())['version'] | |
| py_version = tomllib.loads((root / 'sdks/python/pyproject.toml').read_text())['project']['version'] | |
| mismatches = [] | |
| if ts_version != tag: | |
| mismatches.append(f"TypeScript SDK version is {ts_version}, expected {tag}") | |
| if py_version != tag: | |
| mismatches.append(f"Python SDK version is {py_version}, expected {tag}") | |
| if mismatches: | |
| for mismatch in mismatches: | |
| print(f"::error::{mismatch}") | |
| raise SystemExit(1) | |
| print(f"Validated release tag {tag} against TypeScript and Python SDK versions.") | |
| PY | |
| build-habitat: | |
| name: Build Habitat (${{ matrix.os }}-${{ matrix.arch }}) | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: linux | |
| arch: x86_64 | |
| runner: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| - os: linux | |
| arch: arm64 | |
| runner: ubuntu-latest | |
| goos: linux | |
| goarch: arm64 | |
| - os: macos | |
| arch: arm64 | |
| runner: macos-latest | |
| goos: darwin | |
| goarch: arm64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| cache-dependency-path: habitat/go.sum | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '20' | |
| - name: Build UI | |
| working-directory: habitat | |
| run: | | |
| cd ui | |
| npm install | |
| npm run build | |
| - name: Build Habitat binary | |
| working-directory: habitat | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: | | |
| mkdir -p bin | |
| go build -o bin/habitat ./cmd/habitat | |
| - name: Create artifact name | |
| id: artifact | |
| run: | | |
| echo "name=habitat-${{ matrix.os }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: ${{ steps.artifact.outputs.name }} | |
| path: habitat/bin/habitat | |
| if-no-files-found: error | |
| release: | |
| name: Create Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [build-habitat, validate-release-versions] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: artifacts | |
| - name: Build bundled absurdctl | |
| run: ./scripts/build-absurdctl --standalone-only | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release | |
| # Copy habitat binaries and rename them | |
| cp artifacts/habitat-linux-x86_64/habitat release/habitat-linux-x86_64 | |
| cp artifacts/habitat-linux-arm64/habitat release/habitat-linux-arm64 | |
| cp artifacts/habitat-macos-arm64/habitat release/habitat-macos-arm64 | |
| # Make binaries executable | |
| chmod +x release/habitat-* | |
| # Copy bundled absurdctl | |
| cp dist/absurdctl release/absurdctl | |
| chmod +x release/absurdctl | |
| # Copy SQL file | |
| cp sql/absurd.sql release/absurd.sql | |
| # Extract version from tag and find migration files | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "Release version: $VERSION" | |
| # Copy migration files for this release | |
| # This includes migrations like 0.0.3-0.0.4.sql and potentially 0.0.1-0.0.4.sql | |
| if ls sql/migrations/*-${VERSION}.sql 1> /dev/null 2>&1; then | |
| cp sql/migrations/*-${VERSION}.sql release/ | |
| echo "Copied migration files:" | |
| ls -la sql/migrations/*-${VERSION}.sql | |
| else | |
| echo "No migration files found for version $VERSION" | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| test-python-sdk-pypi-build: | |
| name: Test Python SDK PyPI Build | |
| runs-on: ubuntu-latest | |
| needs: [validate-release-versions] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Build SDK | |
| working-directory: sdks/python | |
| run: uv build | |
| - name: Check package metadata | |
| working-directory: sdks/python | |
| run: uvx twine check dist/* | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: python-sdk-dist | |
| path: sdks/python/dist/ | |
| if-no-files-found: error | |
| test-npm-build: | |
| name: Test npm Package Build | |
| runs-on: ubuntu-latest | |
| needs: [validate-release-versions] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '24' | |
| - name: Install dependencies | |
| working-directory: sdks/typescript | |
| run: npm ci | |
| - name: Build SDK | |
| working-directory: sdks/typescript | |
| run: npm run build | |
| - name: Test package | |
| working-directory: sdks/typescript | |
| run: npm pack | |
| publish-npm: | |
| name: Publish to npm | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [test-npm-build] | |
| runs-on: ubuntu-latest | |
| environment: npm-publish | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| working-directory: sdks/typescript | |
| run: npm ci | |
| - name: Build SDK | |
| working-directory: sdks/typescript | |
| run: npm run build | |
| - name: Publish to npm | |
| working-directory: sdks/typescript | |
| run: npm publish --provenance --access public | |
| test-absurdctl-pypi-build: | |
| name: Test absurdctl PyPI Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Generate absurdctl PyPI staging tree | |
| run: ./scripts/build-absurdctl --pypi-only | |
| - name: Build absurdctl package | |
| run: uv build .build/absurdctl-pypi | |
| - name: Check package metadata | |
| run: uvx twine check .build/absurdctl-pypi/dist/* | |
| - name: Smoke test wheel with uvx | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| wheel=$(echo .build/absurdctl-pypi/dist/absurdctl-*.whl) | |
| uvx --from "$wheel" absurdctl --help | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: absurdctl-dist | |
| path: .build/absurdctl-pypi/dist/ | |
| if-no-files-found: error | |
| publish-pypi: | |
| name: Publish Python SDK to PyPI | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [test-python-sdk-pypi-build] | |
| runs-on: ubuntu-latest | |
| environment: pypi-publish | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Build SDK | |
| working-directory: sdks/python | |
| run: uv build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: sdks/python/dist/ | |
| publish-absurdctl-pypi: | |
| name: Publish absurdctl to PyPI | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [test-absurdctl-pypi-build] | |
| runs-on: ubuntu-latest | |
| environment: pypi-publish | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Generate absurdctl PyPI staging tree | |
| run: ./scripts/build-absurdctl --pypi-only | |
| - name: Build absurdctl package | |
| run: uv build .build/absurdctl-pypi | |
| - name: Publish absurdctl to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: .build/absurdctl-pypi/dist/ |