|
| 1 | +name: Release to Production Branch |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + name: Release to `production` branch |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + ref: master |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Use Node 20 |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: 20 |
| 24 | + - run: yarn install --production=false |
| 25 | + |
| 26 | + - name: Configure git |
| 27 | + run: | |
| 28 | + git config user.name "github-actions[bot]" |
| 29 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 30 | + # user email for github-actions[bot] is found in https://api.github.com/users/github-actions%5Bbot%5D |
| 31 | + |
| 32 | + - name: Bump version number |
| 33 | + id: new_version_number |
| 34 | + run: | |
| 35 | + export RECOMMENDED_BUMP="$(yarn -s conventional-recommended-bump -p angular)" |
| 36 | + echo "Recommended bump: $RECOMMENDED_BUMP" |
| 37 | + npm --commit-hooks=false --git-tag-version=false version $RECOMMENDED_BUMP |
| 38 | + export VERSION=$(jq -r '.version' package.json) |
| 39 | + echo "version=$(echo $VERSION)" >> $GITHUB_OUTPUT |
| 40 | + echo "New version: $VERSION" |
| 41 | +
|
| 42 | + - name: Generate Changelog (CHANGELOG.MD) |
| 43 | + id: changelog |
| 44 | + run: | |
| 45 | + yarn changelog |
| 46 | + git add CHANGELOG.md |
| 47 | + npm \ |
| 48 | + --allow-same-version \ |
| 49 | + --force \ |
| 50 | + --message "build(deploy): Bump to v${{ steps.new_version_number.outputs.version }}" \ |
| 51 | + version ${{ steps.new_version_number.outputs.version }} |
| 52 | +
|
| 53 | + - name: Generate latest changelog (CHANGELOG_LATEST.md) |
| 54 | + run: yarn changelog:latest |
| 55 | + |
| 56 | + - name: Create Release |
| 57 | + uses: softprops/action-gh-release@v2 |
| 58 | + with: |
| 59 | + body_path: CHANGELOG_LATEST.md |
| 60 | + draft: false |
| 61 | + prerelease: false |
| 62 | + generate_release_notes: false |
| 63 | + name: "v${{ steps.new_version_number.outputs.version }}" |
| 64 | + tag_name: "v${{ steps.new_version_number.outputs.version }}" |
| 65 | + |
| 66 | + - name: Push to `production` branch |
| 67 | + run: | |
| 68 | + git checkout production |
| 69 | + git rebase master |
| 70 | + git push origin production |
0 commit comments