-
Notifications
You must be signed in to change notification settings - Fork 427
feat(release): move npm publish to github actions #5464
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
Changes from all commits
278a50b
0ef2c04
87df059
de36836
de4e600
3f45edb
467c80f
7f2563a
f23859a
23e8175
8f92c26
36278fb
9fc5c16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: Manual Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| bump: | ||
| description: 'Version bump type (used if release_version is empty)' | ||
| type: choice | ||
| options: | ||
| - major | ||
| - minor | ||
| - patch | ||
| - prerelease | ||
| required: false | ||
| release_version: | ||
| description: 'Semver version to release (must be > current root version)' | ||
| required: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| id-token: write | ||
| packages: write | ||
|
|
||
| jobs: | ||
| release: | ||
| # Allow only on master, spring*, summer*, winter*; | ||
| if: ${{ github.repository_owner == 'salesforce' && (github.ref_name == 'master' || startsWith(github.ref_name, 'spring') || startsWith(github.ref_name, 'summer') || startsWith(github.ref_name, 'winter')) }} | ||
| environment: release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| registry-url: 'https://registry.npmjs.org' | ||
| cache: 'yarn' | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Resolve version input | ||
| id: resolve_version | ||
| run: | | ||
| RELEASE_VERSION='${{ inputs.release_version }}' | ||
| if [ -z "$RELEASE_VERSION" ]; then | ||
| RELEASE_VERSION='${{ inputs.bump }}' | ||
| fi | ||
| echo "resolved=$RELEASE_VERSION" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Bump versions and commit | ||
| env: | ||
| INPUT_VERSION: ${{ steps.resolve_version.outputs.resolved }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| node ./scripts/release/version.js "$INPUT_VERSION" | ||
| RESOLVED_VERSION=$(jq -r .version package.json) | ||
| git commit -am "chore: release v$RESOLVED_VERSION" | ||
| git push origin HEAD | ||
|
|
||
| - name: Build | ||
| run: yarn build | ||
|
|
||
| - name: Tag and create GitHub release | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| VERSION=$(jq -r .version package.json) | ||
| git tag -a "v$VERSION" -m "Release v$VERSION" | ||
| git push origin tag "v$VERSION" | ||
| gh release create "v$VERSION" --title "v$VERSION" --generate-notes | ||
|
|
||
| - name: Publish to npm | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: | | ||
| TAG=$([ "$GITHUB_REF_NAME" = "master" ] && echo latest || echo "$GITHUB_REF_NAME") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we ensure that we only release using How do we ensure that only repo maintainers can trigger the workflow?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a conditional for branch validation.
This should help with only |
||
| yarn nx release publish --yes --registry https://registry.npmjs.org --tag "$TAG" | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.