diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 063b1c9..53776f5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,7 +8,8 @@ name: Publish # per arch: -, main--, main- # manifest: , main # release published -> the public registry (vars.ACR_PUBLIC_LOGIN_SERVER): , latest -# (version = tag without leading v; latest not moved by pre-releases) +# (releases are cut by release.yml; version = tag without leading v; +# latest not moved by pre-releases) # Not a rebuild: the release commit's image is imported from the # private registry, the same way the openops and tables release # flows promote a tested image. Releasing a commit therefore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c33e6af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,118 @@ +name: Release + +run-name: Release ${{ inputs.version || 'next patch version' }}${{ inputs.draft && ' (draft)' || '' }} + +on: + workflow_dispatch: + inputs: + version: + type: string + description: Override the version, for example to increment minor or major (leave blank for the next patch) + draft: + type: boolean + description: Create the release as a draft (publish it by hand to promote the image) + default: true + +permissions: + contents: write + id-token: write + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +jobs: + release: + name: Create the GitHub release + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + # Required reviewers on this environment are the approval gate for publishing. + environment: release + steps: + - uses: actions/checkout@v7.0.1 + with: + fetch-depth: 0 + + - name: Get next version + if: inputs.version == '' + id: semver + uses: flatherskevin/semver-action@9fb0c115a0bede9fa0743f4823b4182040a4983a # 1.1.5 + with: + incrementLevel: patch + source: tags + + - name: Resolve the version + id: version + env: + VERSION: ${{ inputs.version || steps.semver.outputs.nextVersion }} + run: | + set -euo pipefail + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then + echo "::error::'$VERSION' is not a bare semantic version (no leading v)" >&2 + exit 1 + fi + if git rev-parse --quiet --verify "refs/tags/$VERSION" >/dev/null; then + echo "::error::Tag $VERSION already exists" >&2 + exit 1 + fi + prerelease=false + if [[ "$VERSION" == *-* ]]; then + prerelease=true + fi + { + echo "version=$VERSION" + echo "prerelease=$prerelease" + } >> "$GITHUB_OUTPUT" + + - name: Azure login + uses: azure/login@v3.0.2 + with: + client-id: ${{ secrets.AZURE_ACR_RELEASE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Check the image for this commit exists in the private registry + # promote imports rather than rebuilds, so a commit whose main build was never + # published, or was already cleaned up, cannot be released. + env: + ACR_NAME: ${{ vars.ACR_NAME }} + ACR_LOGIN_SERVER: ${{ vars.ACR_LOGIN_SERVER }} + run: | + set -euo pipefail + : "${ACR_NAME:?must be set to the private registry name}" + short_sha="${GITHUB_SHA:0:8}" + if ! az acr manifest show-metadata --registry "$ACR_NAME" --name "openops-mcp:$short_sha" --only-show-errors >/dev/null; then + echo "::error::No image $ACR_LOGIN_SERVER/openops-mcp:$short_sha. Release a commit on main whose Publish run succeeded." >&2 + exit 1 + fi + + - name: Create the GitHub release + id: release + uses: softprops/action-gh-release@v3.0.3 + with: + target_commitish: ${{ github.sha }} + tag_name: ${{ steps.version.outputs.version }} + name: ${{ steps.version.outputs.version }} + generate_release_notes: true + draft: ${{ inputs.draft }} + prerelease: ${{ steps.version.outputs.prerelease == 'true' }} + + - name: Write summary + env: + VERSION: ${{ steps.version.outputs.version }} + DRAFT: ${{ inputs.draft }} + RELEASE_URL: ${{ steps.release.outputs.url }} + run: | + { + echo "### Release $VERSION" + echo + echo "- Commit: \`${GITHUB_SHA:0:8}\`" + echo "- Draft: \`$DRAFT\`" + echo + if [ "$DRAFT" = "true" ]; then + edit_url="$(printf '%s' "$RELEASE_URL" | sed 's#/releases/tag/#/releases/edit/#')" + echo "Please [review and publish it]($edit_url) to promote the image to \`openops-mcp:$VERSION\` in the public registry." + else + echo "The Publish workflow is now promoting the image to \`openops-mcp:$VERSION\` in the public registry." + fi + } >> "$GITHUB_STEP_SUMMARY" diff --git a/README.md b/README.md index cbfd815..2d252ed 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,8 @@ Resources → Network) and point `OPENOPS_API_URL` and `OPENOPS_MCP_ISSUER` at Published images (multi-arch, amd64 and arm64) come from the Publish workflow: releases go to `openops.azurecr.io/openops-mcp:` (and `latest`), pullable anonymously; pushes to -`main` go to the private `openopsprivate.azurecr.io/openops-mcp:main`. +`main` go to the private `openopsprivate.azurecr.io/openops-mcp:main`. See +[Releasing](#releasing) for how a release is cut. ## Configuration reference @@ -287,3 +288,19 @@ provider against a mocked API and authorization server, so the authentication pa exercised rather than stubbed. [docs/architecture.md](docs/architecture.md) covers how the pieces fit together and why. + +## Releasing + +Releases are cut with the **Release** workflow, run from `main`: + +1. Wait for the Publish run of the commit you want to release, so its image exists in the + private registry. +2. Run **Release**. Leave `version` blank for the next patch after the latest tag, or set it + to bump minor or major (with no tags yet, blank would mean `0.0.1`, so the first release + sets it explicitly). It checks the image is there, then creates the tag and a draft + GitHub release named after the version (no `v` prefix). +3. Publish the draft. That triggers the promote job, which imports the image into + `openops.azurecr.io/openops-mcp:` and moves `latest` unless the version has a + pre-release suffix. + +The `version` in `pyproject.toml` is informational; the released version is the git tag. diff --git a/pyproject.toml b/pyproject.toml index cd43244..0e7056a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ build-backend = "hatchling.build" [project] name = "openops-mcp" +# Informational only: the released version is the git tag (see the Release workflow). version = "0.2.0" description = "MCP server exposing OpenOps API operations as tools" requires-python = ">=3.14,<3.15"