Skip to content

Commit 4f0f2b7

Browse files
committed
ci: automatically add tag and create release
1 parent 1d4dcc2 commit 4f0f2b7

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

.github/workflows/release.yml

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

33
on:
4-
push:
5-
tags:
6-
- "v*"
4+
pull_request_target:
5+
types: [closed]
6+
branches:
7+
- main
78

89
# Remove default permissions of GITHUB_TOKEN for security
910
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
1011
permissions: {}
1112

1213
jobs:
1314
release:
14-
if: github.repository_owner == 'nuxt'
15+
if: github.repository == 'nuxt/bridge' && github.event.pull_request.merged == true && (startsWith(github.event.pull_request.head.ref, 'v3.') || startsWith(github.event.pull_request.head.ref, 'v4.'))
16+
concurrency:
17+
group: release
1518
permissions:
19+
contents: write
1620
id-token: write
1721
runs-on: ubuntu-latest
1822
timeout-minutes: 20
@@ -27,8 +31,25 @@ jobs:
2731
registry-url: "https://registry.npmjs.org/"
2832
cache: "pnpm"
2933

30-
- name: Install dependencies
34+
- name: 📦 Install dependencies
3135
run: pnpm install
3236

33-
- name: Release
37+
- name: 🛠 Build and release project
3438
run: ./scripts/release.sh
39+
env:
40+
TAG: latest
41+
42+
- name: 🏷️ Create tag
43+
env:
44+
TAG_NAME: ${{ github.event.pull_request.head.ref }}
45+
run: |
46+
git tag "$TAG_NAME"
47+
git push origin "$TAG_NAME"
48+
49+
- name: 🛳️ Create GitHub release
50+
env:
51+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
TAG_NAME: ${{ github.event.pull_request.head.ref }}
53+
RELEASE_NAME: ${{ github.event.pull_request.head.ref }}
54+
BODY: ${{ github.event.pull_request.body }}
55+
run: gh release create "$TAG_NAME" --title "$RELEASE_NAME" --notes "$BODY"

0 commit comments

Comments
 (0)