Release #29
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: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: | |
| - completed | |
| branches: [ main ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # Permissions needed for the release workflow | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| repository-projects: write | |
| jobs: | |
| release: | |
| # Only run if CI workflow completed successfully and on main branch push (not PR) | |
| if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install just | |
| uses: extractions/setup-just@v1 | |
| - name: Install cocogitto | |
| uses: cocogitto/cocogitto-action@v3 | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Setup git config | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Check if there are releasable changes | |
| id: check_changes | |
| run: | | |
| echo "Validating commits since last tag..." # output: cog lint log | |
| if ! cog check --from-latest-tag; then | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "Checking for releasable conventional commits..." # output: true when bump possible | |
| if cog bump --auto --dry-run; then | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "No releasable changes detected; skipping release." # output: log only | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| continue-on-error: true | |
| - name: Create release | |
| if: steps.check_changes.outputs.has_changes == 'true' | |
| id: create_release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Generate changelog and bump version | |
| cog bump --auto | |
| NEW_TAG=$(git describe --tags --abbrev=0) | |
| NEW_VERSION=${NEW_TAG#v} | |
| git push origin HEAD | |
| git push origin "${NEW_TAG}" | |
| echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| # Generate changelog for the release | |
| cog changelog --at "${NEW_TAG}" > RELEASE_NOTES.md | |
| # Create GitHub release | |
| gh release create "${NEW_TAG}" \ | |
| --title "Release v${NEW_VERSION}" \ | |
| --notes-file RELEASE_NOTES.md \ | |
| --draft=false \ | |
| --prerelease=false | |
| - name: Set version output | |
| id: get_version | |
| run: | | |
| if [ "${{ steps.check_changes.outputs.has_changes }}" == "true" ]; then | |
| echo "version=${{ steps.create_release.outputs.version }}" >> "$GITHUB_OUTPUT" | |
| else | |
| # If no release was created, get the latest tag version | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.1.0") | |
| VERSION=${LATEST_TAG#v} | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| fi | |
| publish: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull latest changes from release | |
| run: | | |
| git pull origin main | |
| git fetch --tags | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install just | |
| uses: extractions/setup-just@v1 | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Publish to crates.io | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: | | |
| # Check if we have a cargo registry token | |
| if [ -z "$CARGO_REGISTRY_TOKEN" ]; then | |
| echo "CARGO_REGISTRY_TOKEN is not set, skipping crates.io publication" | |
| exit 0 | |
| fi | |
| # Publish library first | |
| cd just-mcp-lib | |
| cargo publish --token ${CARGO_REGISTRY_TOKEN} || echo "Library publish failed or already published" | |
| # Wait a bit for the library to be available | |
| sleep 30 | |
| # Publish binary crate | |
| cd .. | |
| cargo publish --token ${CARGO_REGISTRY_TOKEN} || echo "Binary crate publish failed or already published" | |
| container: | |
| needs: release | |
| uses: ./.github/workflows/container.yaml | |
| permissions: | |
| contents: read | |
| packages: write | |
| with: | |
| version: ${{ needs.release.outputs.version }} | |
| if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }} | |
| publish-mcp-registry: | |
| needs: | |
| - release | |
| - container | |
| if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install MCP Publisher | |
| run: | | |
| curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher | |
| - name: Login to MCP Registry | |
| run: ./mcp-publisher login github-oidc | |
| - name: Publish server metadata | |
| run: ./mcp-publisher publish |