-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(release): automatically create pr release and update its title bas…
…ed on commits (#529)
- Loading branch information
1 parent
7568e14
commit 244845a
Showing
4 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Werewolves Assistant API Release Workflow | ||
name: 🚀 Release Workflow | ||
|
||
on: | ||
push: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: 🔃️ Upsert PR Release Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- "develop" | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
install: | ||
name: Install ⚙️ | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout GitHub repository 📡 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup NodeJS ⚙️ | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
|
||
- name: Cache npm dependencies 🥡 | ||
uses: actions/cache@v3 | ||
id: cache-node-modules | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }} | ||
|
||
- name: Install project dependencies 📦 | ||
run: npm ci --ignore-scripts | ||
if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
|
||
get-next-release-version: | ||
name: Get next release version 🏷️ | ||
runs-on: ubuntu-latest | ||
needs: | ||
- install | ||
steps: | ||
- name: Checkout GitHub repository 📡 | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Setup NodeJS ⚙️ | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
|
||
- name: Restore npm dependencies from cache 🥡 | ||
uses: actions/cache/restore@v3 | ||
id: cache-node-modules | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-npm-v3-${{ hashFiles('package-lock.json') }} | ||
|
||
- name: Get next release version 🏷️ | ||
id: release | ||
run: npx semantic-release --dry-run --no-ci | ||
|
||
outputs: | ||
new-release-published: ${{ steps.release.outputs.new-release-published }} | ||
new-release-version: ${{ steps.release.outputs.new-release-version }} | ||
|
||
upsert-pr-release: | ||
name: Upsert Pull Request Release 🔃 | ||
runs-on: ubuntu-latest | ||
needs: | ||
- get-next-release-version | ||
steps: | ||
- name: Checkout GitHub repository 📡 | ||
uses: actions/checkout@v4 | ||
|
||
- name: List open PR into main 📋 | ||
run: | | ||
OPEN_PR_INTO_MAIN=$(gh pr list --state open -B main --search "Release in:title" --json number,title) | ||
echo "OPEN_PR_INTO_MAIN=$OPEN_PR_INTO_MAIN" >> $GITHUB_ENV | ||
- name: Set PR Title 🔤 | ||
run: | | ||
PR_TITLE="Release v${{ needs.get-next-release-version.outputs.new-release-version }}" | ||
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV | ||
- name: Determine action to perform on PR 🚏 | ||
run: | | ||
if [[ "$OPEN_PR_INTO_MAIN" != "[]" ]]; then | ||
PR_NUMBER=$(echo "$OPEN_PR_INTO_MAIN" | jq -r '.[0].number') | ||
if [[ -n "$PR_NUMBER" ]]; then | ||
echo "PR_ACTION=update" >> $GITHUB_ENV | ||
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | ||
else | ||
echo "PR_ACTION=create" >> $GITHUB_ENV | ||
fi | ||
else | ||
echo "PR_ACTION=create" >> $GITHUB_ENV | ||
fi | ||
- name: Create Release PR if it doesn't exist 🔃 | ||
if: env.PR_ACTION == 'create' | ||
run: gh pr create --repo "${{ github.repository }}" --title "${{ env.PR_TITLE }}" --body "" --assignee "antoinezanardi" --label "🏷️ release" --base main --head develop | ||
|
||
- name: Update Release PR if it exists 🔃 | ||
if: env.PR_ACTION == 'update' | ||
run: gh pr edit ${{ env.PR_NUMBER }} --repo "${{ github.repository }}" --title "${{ env.PR_TITLE }}" |