-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (83 loc) · 2.39 KB
/
Copy pathcreate-release.yml
File metadata and controls
104 lines (83 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Create Release
on:
workflow_dispatch:
pull_request:
branches:
- main
types: [ closed ]
jobs:
test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get and cache dependencies
uses: ./.github/actions/cached-deps
- name: Lint code
run: npm run lint
- name: Test
run: npm run test
build:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get and cache dependencies
uses: ./.github/actions/cached-deps
- name: Build
run: npm run build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-files
path: dist
create_release:
name: Create Release
needs: build
permissions:
contents: write
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release'))
runs-on: ubuntu-latest
steps:
- name: Get code
uses: actions/checkout@v4
- name: Get build artifacts
uses: actions/download-artifact@v4
with:
name: dist-files
path: ./dist
- name: Output contents
run: ls -R
- name: Create Release
id: create_release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
# Read version from package.json
version=$(jq -r .version package.json)
# Create zip file of dist folder
zip -r dist.zip ./dist
# Create the release using GitHub CLI
gh release create "$version" \
--title "Release $version" \
--draft=false \
--prerelease=false \
--generate-notes \
dist.zip
cleanup_branch:
name: Remove release branch
needs: create_release
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Delete release branch
uses: actions/github-script@v7
with:
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'heads/release/next-version'
})