Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ name: Draft new release
on:
workflow_dispatch

permissions:
contents: read

jobs:
draft-new-release:
permissions:
contents: write # for Git to git push
name: Draft a new release
runs-on: ubuntu-latest
permissions:
contents: read # to read repository contents
if: startsWith(github.ref, 'refs/heads/fix/') || startsWith(github.ref, 'refs/heads/feature/')
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
egress-policy: audit

- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PRIVATE_KEY }}
permission-contents: write # to create commits, tags, and push branches
permission-pull-requests: write # to create and update PRs

- name: Checkout source branch
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0

- name: Set Node 16
uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1
with:
node-version: 16

# In order to make a commit, we need to initialize a user.
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
- name: Initialize mandatory git config
run: |
git config user.name "GitHub actions"
git config user.email noreply@github.com

# Calculate the next release version based on conventional semantic release
- name: Create release branch
Expand All @@ -59,15 +59,23 @@ jobs:
echo "Release type is $release_type"
echo "New version is $new_version"
echo "New release branch name is $branch_name"
git checkout -b "$branch_name"
git push --set-upstream origin "$branch_name"


echo "source_branch_name=$source_branch_name" >> $GITHUB_OUTPUT
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
echo "NEW_VERSION_VALUE=$new_version" >> $GITHUB_ENV

- name: Create release branch via GitHub API
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
BASE_SHA=$(git rev-parse HEAD)
gh api repos/${{ github.repository }}/git/refs \
--method POST \
-f ref="refs/heads/${{ steps.create-release.outputs.branch_name }}" \
-f sha="$BASE_SHA"

- name: Update changelog & bump version
id: finish-release
env:
Expand All @@ -79,21 +87,30 @@ jobs:
echo "Current version: $CURRENT_VERSION_VALUE"
echo "New version: $NEW_VERSION_VALUE"
npx replace $CURRENT_VERSION_VALUE $NEW_VERSION_VALUE README.md
git add README.md
echo ${{ steps.create-release.outputs.new_version }}
echo "commit_summary=$SUMMARY" >> $GITHUB_OUTPUT
npx standard-version -a
npx standard-version -a --skip.commit --skip.tag

- name: Push new version in release branch & tag
run: |
git push --follow-tags
- name: Create verified commit and tag via GitHub API
uses: ryancyq/github-signed-commit@e9f3b28c80da7be66d24b8f501a5abe82a6b855f # v1.2.0
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
with:
branch-name: ${{ steps.create-release.outputs.branch_name }}
commit-message: 'chore(release): v${{ steps.create-release.outputs.new_version }}'
files: |
CHANGELOG.md
package.json
package-lock.json
README.md
tag: 'v${{ steps.create-release.outputs.new_version }}'

- name: Create pull request into master
uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5 # v2.12.1
with:
source_branch: ${{ steps.create-release.outputs.branch_name }}
destination_branch: 'master'
github_token: ${{ secrets.PAT }}
github_token: ${{ steps.generate-token.outputs.token }}
pr_title: "chore(release): pulling ${{ steps.create-release.outputs.branch_name }} into master"
pr_body: ":crown: *An automated PR*\n\n${{ steps.finish-release.outputs.commit_summary }}"
pr_reviewer: 'pallabmaiti'
4 changes: 3 additions & 1 deletion .github/workflows/notion-pr-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ on:
jobs:
request:
runs-on: ubuntu-latest
permissions:
pull-requests: read # to read PR metadata for Notion sync
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
Expand All @@ -57,4 +59,4 @@ jobs:
with:
notionKey: ${{ secrets.NOTION_BOT_KEY }}
notionDatabaseId: ${{ secrets.NOTION_PR_DB_ID }}
githubKey: ${{ secrets.PAT }}
githubKey: ${{ secrets.GITHUB_TOKEN }}
15 changes: 13 additions & 2 deletions .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ jobs:
release:
name: Publish new release
runs-on: ubuntu-latest
permissions:
contents: read # to read repository contents
if: startsWith(github.event.pull_request.head.ref, 'release/') && github.event.pull_request.merged == true # only merged pull requests must trigger this job
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
egress-policy: audit

- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_PRIVATE_KEY }}
permission-contents: write # to create tags and releases

- name: Extract version from branch name (for release branches)
id: extract-version
run: |
Expand All @@ -28,6 +38,7 @@ jobs:
- name: Checkout source branch
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
token: ${{ steps.generate-token.outputs.token }}
fetch-depth: 0

- name: Set Node 16
Expand All @@ -39,8 +50,8 @@ jobs:
id: create_release
env:
HUSKY: 0
GITHUB_TOKEN: ${{ secrets.PAT }}
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ secrets.PAT }}
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
npx conventional-github-releaser -p angular

Expand Down
Loading