-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add workflow to publish v1.x releases on tag push #1367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ffec70a
feat: add workflow to release v1.x versions from main branch
pcarleton dfb81dd
refactor: trigger on v1.* tag push instead of workflow_dispatch
pcarleton 699f607
fix: add top-level permissions block for CodeQL
pcarleton 758d80b
Add workflow_dispatch for manual releases and document v1.x release p…
pcarleton 9f27dd8
Add concurrency control to prevent duplicate runs
pcarleton d68cb4b
Merge branch 'main' into feat/v1x-release-workflow
pcarleton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Publish v1.x releases when a v1.* tag is pushed | ||
| # This allows releasing from the v1.x branch without switching GitHub's default branch | ||
| # | ||
| # Usage: | ||
| # git checkout v1.x | ||
| # npm version patch # bumps version and creates tag | ||
| # git push origin v1.x --tags | ||
| # | ||
| # The workflow will automatically build, test, and publish to npm. | ||
|
|
||
| name: Publish v1.x | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v1.*' | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
| cache: npm | ||
|
|
||
| - run: npm ci | ||
| - run: npm run check | ||
| - run: npm run build | ||
|
|
||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node-version: [18, 24] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: npm | ||
|
|
||
| - run: npm ci | ||
| - run: npm test | ||
|
|
||
| publish: | ||
|
||
| runs-on: ubuntu-latest | ||
| needs: [build, test] | ||
| environment: release | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
| cache: npm | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - run: npm ci | ||
|
|
||
| - name: Determine npm tag | ||
| id: npm-tag | ||
| run: | | ||
| VERSION=$(node -p "require('./package.json').version") | ||
| # Use "release-X.Y" as tag for v1.x releases | ||
| # This allows users to install specific minor versions: | ||
| # npm install @modelcontextprotocol/sdk@release-1.25 | ||
| MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2) | ||
| echo "tag=release-${MAJOR_MINOR}" >> $GITHUB_OUTPUT | ||
|
|
||
| - run: npm publish --provenance --access public --tag ${{ steps.npm-tag.outputs.tag }} | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.