forked from richardsimko/update-tag
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (116 loc) · 3.94 KB
/
publish.yml
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
name: Publish
on:
workflow_dispatch:
inputs:
versionType:
type: choice
description: '<major|minor|patch>'
required: true
default: 'minor'
options:
- major
- minor
- patch
jobs:
publish:
name: Publish ${{ inputs.versionType }} release
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Prepare Node
uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION}}
cache: 'yarn'
- id: update-version
shell: bash
name: Update package.json version
# Use npm because yarn is for some reason not able to output only the version name
run: |
echo "version=$(npm version --no-git-tag-version ${{ inputs.versionType }})" >> $GITHUB_OUTPUT
git add .
- uses: planetscale/[email protected]
name: Commit new version
with:
commit_message: "🤖 Release ${{steps.update-version.outputs.version}}"
repo: ${{ github.repository }}
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout release branch
shell: bash
run: |
git checkout -b release/${{steps.update-version.outputs.version}}
git push origin release/${{steps.update-version.outputs.version}}
- name: Install
run: yarn install --frozen-lockfile
- name: Build
run: yarn run build
- name: Install prod dependencies
run: rm -rf node_modules && yarn install --production --frozen-lockfile
- name: Add node_modules and dist
shell: bash
run: |
git add --force dist/
git add --force node_modules/
- uses: planetscale/[email protected]
name: Commit node_modules and dist
with:
commit_message: "🤖 Build ${{steps.update-version.outputs.version}}"
repo: ${{ github.repository }}
branch: release/${{steps.update-version.outputs.version}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
id: tag
shell: bash
run: |
git tag ${{steps.update-version.outputs.version}}
git push origin ${{steps.update-version.outputs.version}}
git push origin --delete release/${{steps.update-version.outputs.version}}
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: 'Build Changelog'
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
token: '${{ github.token }}'
configurationJson: |
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix"]
},
{
"title": "## 💬 Other",
"labels": ["other"]
},
{
"title": "## 📦 Dependencies",
"labels": ["dependencies"]
},
{
"title": "## ❓ Uncategorized",
"labels": []
}
]
}
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
body: ${{steps.build_changelog.outputs.changelog}}
name: ${{steps.update-version.outputs.version}}
tag_name: ${{steps.update-version.outputs.version}}
target_commitish: ${{ steps.tag.outputs.sha }}