-
Notifications
You must be signed in to change notification settings - Fork 3
131 lines (118 loc) · 4.02 KB
/
Copy pathrelease.yml
File metadata and controls
131 lines (118 loc) · 4.02 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: release
on:
workflow_dispatch:
inputs:
package:
description: 'Package to release'
required: true
type: choice
options:
- 'wobe'
- 'wobe-graphql-yoga'
- 'wobe-graphql-apollo'
- 'wobe-validator'
jobs:
release:
runs-on: ubuntu-latest
name: 'Release ${{inputs.package}}'
permissions:
contents: write
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
registries: 'https://registry.npmjs.org'
- run: bun install
- run: bun run ci
- run: bun build:wobe
- run: bun --filter ./packages/${{inputs.package}} build
- name: 'Get Previous tag'
id: previousTag
run: |
echo "Fetching tags..."
previous_tag=$(git tag -l "${{inputs.package}}-[0-9]*" --sort=-v:refname | head -n 1)
echo "Found previous tag: $previous_tag"
echo "tag=$previous_tag" >> $GITHUB_ENV
- name: 'Get Next Version from package.json'
id: nextVersion
run: |
package_json_path="./packages/${{inputs.package}}/package.json"
if [ ! -f "$package_json_path" ]; then
echo "Error: $package_json_path not found."
exit 1
fi
next_version=$(jq -r .version < "$package_json_path")
if [ -z "$next_version" ]; then
echo "Error: Version not found in $package_json_path."
exit 1
fi
echo "Next version: $next_version"
echo "next_version=$next_version" >> $GITHUB_ENV
# We publish on NPM before releasing on GitHub to avoid releasing a version that is not published
- run: cd packages/${{inputs.package}} && bun publish --access=public
env:
NPM_CONFIG_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Create tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{inputs.package}}-${{env.next_version}}',
sha: context.sha
})
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v4.2.2
with:
fromTag: ${{ env.tag }}
toTag: ${{inputs.package}}-${{env.next_version}}
configurationJson: |
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feat"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix", "bug"]
},
{
"key": "tests",
"title": "## 🧪 Tests",
"labels": ["test"]
},
{
"key": "doc",
"title": "## 📚 Documentation",
"labels": ["docs", "doc"]
},
{
"key": "misc",
"title": "## 💬 Miscellaneous",
"labels": ["ci", "chore", "perf", "refactor"]
}
],
"template": "#{{CHANGELOG}}\n\n",
"pr_template": "- #{{TITLE}} (by @#{{AUTHOR}} in ##{{NUMBER}}) ",
"label_extractor": [
{
"pattern": "^(ci|chore|doc|docs|feat|fix|bug|perf|refactor|test|tests)\\(${{inputs.package}}\\):(.*)",
"target": "$1",
"on_property": "title"
}
]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{inputs.package}}-${{env.next_version}}
body: ${{steps.github_release.outputs.changelog}}