Log, contain, and cleanly surface Bedrock mid-stream errors on the fa… #38
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 | |
| # A pushed tag builds + tests, then publishes a GitHub release with the binary. | |
| # The VM auto-updater pulls that release; that is the only deploy path we care | |
| # about. npm/PyPI are NOT published on a tag; they are manual opt-in only via | |
| # the workflow_dispatch toggles below. | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| publish_npm: | |
| description: "Also publish to npm (manual opt-in)" | |
| required: true | |
| type: boolean | |
| default: false | |
| publish_pypi: | |
| description: "Also publish to PyPI (manual opt-in)" | |
| required: true | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: read | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| build: | |
| name: Build and verify artifacts | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Determine release version | |
| id: version | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
| version="${GITHUB_REF_NAME#v}" | |
| else | |
| version="$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')" | |
| fi | |
| echo "version=${version}" >> "${GITHUB_OUTPUT}" | |
| - name: Test Go packages | |
| run: CGO_ENABLED=0 go test ./... | |
| - name: Build Go release binaries | |
| run: scripts/build-release.sh "${{ steps.version.outputs.version }}" | |
| - name: Copy shell installer into release assets | |
| run: cp install.sh dist/release/install.sh | |
| - name: Upload Go release artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: release-assets | |
| path: dist/release/* | |
| if-no-files-found: error | |
| github-release: | |
| name: Publish GitHub release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download Go release artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: release-assets | |
| path: dist/release | |
| - name: Create or update GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} | |
| TAG_NAME: v${{ needs.build.outputs.version }} | |
| run: | | |
| set -euo pipefail | |
| if gh release view "${TAG_NAME}" >/dev/null 2>&1; then | |
| gh release upload "${TAG_NAME}" dist/release/* --clobber | |
| else | |
| gh release create "${TAG_NAME}" dist/release/* \ | |
| --title "Subrouter ${TAG_NAME}" \ | |
| --notes "Subrouter ${TAG_NAME}" | |
| fi | |
| # Manual opt-in only. These never run on a tag push; trigger this workflow via | |
| # the Actions "Run workflow" button with the toggle enabled to publish. | |
| npm-publish: | |
| name: Publish npm package (manual) | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_npm }} | |
| environment: npm | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Publish to npm | |
| run: npm publish --access public | |
| pypi-publish: | |
| name: Publish PyPI package (manual) | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_pypi }} | |
| environment: pypi | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Build Python package | |
| run: | | |
| python -m pip install --upgrade build twine | |
| python -m build | |
| python -m twine check dist/subrouter-*.tar.gz dist/subrouter-*.whl | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |