chore(release): 1.36.0 (#114) #72
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: | |
| push: | |
| branches: | |
| - master | |
| env: | |
| HUSKY: 0 | |
| jobs: | |
| release: | |
| permissions: | |
| contents: write # for release publishing | |
| pull-requests: write # for creating PRs | |
| issues: write # additional permission that might be needed | |
| name: Release | |
| env: | |
| commitmsg: ${{ github.event.head_commit.message }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v3 | |
| with: | |
| node-version: lts/* | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile --non-interactive | |
| - run: yarn build | |
| - name: Release | |
| id: semantic_release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npx semantic-release | |
| - name: Create PR with release changes | |
| if: ${{ success() && steps.semantic_release.outcome == 'success' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Check if there are any changes to commit | |
| if [[ -n $(git status --porcelain) ]]; then | |
| # Get the version from package.json | |
| VERSION=$(node -p "require('./package.json').version") | |
| BRANCH_NAME="release/v${VERSION}" | |
| echo "Creating PR for release version: ${VERSION}" | |
| # Create and switch to new branch | |
| git checkout -b $BRANCH_NAME | |
| # Configure git | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| # Add and commit changes (only add files that exist) | |
| git add package.json || true | |
| git add yarn.lock || true | |
| git add CHANGELOG.md || true | |
| # Check if there are actually changes to commit after adding | |
| if [[ -n $(git diff --cached --name-only) ]]; then | |
| git commit -m "chore(release): ${VERSION}" | |
| # Push the branch | |
| git push origin $BRANCH_NAME | |
| # Create PR using GitHub CLI | |
| gh pr create \ | |
| --title "chore(release): ${VERSION}" \ | |
| --body "Automated release PR for version ${VERSION} | |
| This PR contains: | |
| - Updated package.json version | |
| - Updated yarn.lock (if changed) | |
| - Updated CHANGELOG.md | |
| Please review and merge to complete the release process." \ | |
| --head $BRANCH_NAME \ | |
| --base master | |
| echo "Created PR for release ${VERSION}" | |
| else | |
| echo "No changes to commit after staging files" | |
| git checkout master | |
| git branch -D $BRANCH_NAME | |
| fi | |
| else | |
| echo "No changes detected after semantic-release" | |
| fi |