forked from au-re/rimless
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (68 loc) · 2.53 KB
/
publish-release.yml
File metadata and controls
78 lines (68 loc) · 2.53 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
name: Publish Package
on:
pull_request:
types: [closed]
branches:
- master
permissions:
contents: write
jobs:
test-and-build:
name: Test and build
uses: ./.github/workflows/test-and-build.yml
publish:
if: github.event.pull_request.merged == true && (contains(github.event.pull_request.labels.*.name, 'release:major') || contains(github.event.pull_request.labels.*.name, 'release:minor') || contains(github.event.pull_request.labels.*.name, 'release:patch'))
needs: test-and-build
runs-on: ubuntu-latest
steps:
- name: Determine version type from label
id: version-type
run: |
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
if echo $LABELS | grep -a "release:major"; then
VERSION_TYPE="major"
elif echo $LABELS | grep -a "release:minor"; then
VERSION_TYPE="minor"
elif echo $LABELS | grep -a "release:patch"; then
VERSION_TYPE="patch"
else
echo "::error::No valid release label found (release:major, release:minor, release:patch)."
exit 1
fi
echo "type=$VERSION_TYPE" >> $GITHUB_OUTPUT
echo "Running a $VERSION_TYPE release"
- name: Configure git access
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.JAM_GIT_PUSHER_APP_ID }}
private-key: ${{ secrets.JAM_GIT_PUSHER_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: "master"
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Configure git author
run: |
git config user.name GitHub Actions
git config user.email github-actions@github.com
- name: Tag release
id: bump-version
run: |
npm version "${{ steps.version-type.outputs.type }}"
echo "new_version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
# Run this after the build! So we only push tags if the build is successful
- name: Push tags
run: git push --tags origin HEAD
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.bump-version.outputs.new_version }}
release_name: v${{ steps.bump-version.outputs.new_version }}
draft: false
prerelease: false