fix: add new release PR process #71
Workflow file for this run
This file contains 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: Merge Release PR and Publish | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
concurrency: | |
group: release | |
cancel-in-progress: false | |
jobs: | |
publish: | |
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release-v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Common Setup | |
uses: ./.github/actions/setup | |
- name: Configure NPM authentication | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
npm config set @d11:registry https://registry.npmjs.org/ | |
- name: Check NPM config | |
run: npm config list | |
- name: Extract version from release branch name | |
id: extract_version | |
run: | | |
TAG_NAME=${{ github.event.pull_request.head.ref }} | |
VERSION=${TAG_NAME#release-} # Remove 'release-' prefix | |
echo "VERSION=$VERSION" >> $GITHUB_ENV # Save version as environment variable | |
shell: bash | |
- name: Publish to npm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm publish --tag latest | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} # Use the extracted version | |
release_name: ${{ env.VERSION }} # Use the extracted version | |
draft: false | |
prerelease: false |