Skip to content

Commit 6ae5b5f

Browse files
committed
ci: automate release on merge of of v3/v4
1 parent be5d85f commit 6ae5b5f

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
name: release
22

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
pull_request_target:
5+
types: [closed]
6+
branches:
7+
- main
8+
- 3.x
79

810
# Remove default permissions of GITHUB_TOKEN for security
911
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
1012
permissions: {}
1113

1214
jobs:
1315
release:
14-
if: github.repository == 'nuxt/nuxt' && (startsWith(github.event.head_commit.message, 'v3.') || startsWith(github.event.head_commit.message, 'v4.'))
16+
if: github.repository == 'nuxt/nuxt' && github.event.pull_request.merged == true && (startsWith(github.event.pull_request.head.ref, 'v3.') || startsWith(github.event.pull_request.head.ref, 'v4.'))
1517
concurrency:
1618
group: release
1719
permissions:
20+
contents: write
1821
id-token: write
1922
runs-on: ubuntu-latest
2023
timeout-minutes: 20
@@ -29,14 +32,28 @@ jobs:
2932
registry-url: "https://registry.npmjs.org/"
3033
cache: "pnpm"
3134

32-
- name: Install dependencies
35+
- name: 📦 Install dependencies
3336
run: pnpm install
3437

3538
- name: Build (stub)
3639
run: pnpm dev:prepare
3740

38-
- name: Release
41+
- name: 🛠 Build and release project
3942
run: ./scripts/release.sh
4043
env:
4144
NODE_AUTH_TOKEN: ${{secrets.RELEASE_NODE_AUTH_TOKEN}}
4245
NPM_CONFIG_PROVENANCE: true
46+
47+
- name: 🏷️ Create tag
48+
run: |
49+
TAG_NAME=${{ github.event.pull_request.head.ref }}
50+
git tag $TAG_NAME
51+
git push origin $TAG_NAME
52+
53+
- name: 🛳️ Create GitHub release
54+
run: gh release create $TAG_NAME --title "$RELEASE_NAME" --notes "$BODY"
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
TAG_NAME: ${{ github.event.pull_request.head.ref }}
58+
RELEASE_NAME: ${{ github.event.pull_request.head.ref }}
59+
BODY: ${{ github.event.pull_request.body }}

0 commit comments

Comments
 (0)