-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (87 loc) · 3.46 KB
/
release.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
# Automatically Create a Release when PR is merged to main with one of the following
# labels: "patch", "minor", "major", "alpha", "beta", "rc".
name: Auto Release
# Controls when the action will run.
on:
pull_request:
types: [ closed ]
branches: [ main ]
jobs:
release:
name: Release
timeout-minutes: 10
runs-on: ubuntu-latest
# Only run on merged PRs with an appropriate label.
if: |
github.event.pull_request.merged &&
(
contains(github.event.pull_request.labels.*.name, 'patch') ||
contains(github.event.pull_request.labels.*.name, 'minor') ||
contains(github.event.pull_request.labels.*.name, 'major') ||
contains(github.event.pull_request.labels.*.name, 'alpha') ||
contains(github.event.pull_request.labels.*.name, 'beta') ||
contains(github.event.pull_request.labels.*.name, 'rc')
)
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Specify a different token to allow pushing changes to main later
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
- name: Set Git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
# Increment version based on label
- name: Patch Release tag
if: ${{ contains( github.event.pull_request.labels.*.name, 'patch') }}
run: npm version patch
- name: Minor Release tag
if: ${{ contains( github.event.pull_request.labels.*.name, 'minor') }}
run: npm version minor
- name: Major Release tag
if: ${{ contains( github.event.pull_request.labels.*.name, 'major') }}
run: npm version major
- name: Alpha Release tag
if: ${{ contains( github.event.pull_request.labels.*.name, 'alpha') }}
run: |
npm version prerelease --preid alpha
echo "PRERELEASE=true" >> $GITHUB_ENV
- name: Beta Release tag
if: ${{ contains( github.event.pull_request.labels.*.name, 'beta') }}
run: |
npm version prerelease --preid beta
echo "PRERELEASE=true" >> $GITHUB_ENV
- name: RC Release tag
if: ${{ contains( github.event.pull_request.labels.*.name, 'rc') }}
run: |
npm version prerelease --preid rc
echo "PRERELEASE=true" >> $GITHUB_ENV
# Push commits back to origin repo.
- name: Push Changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
branch: ${{ github.base_ref }}
tags: true
- name: Set enviroment variables for release notes.
id: getreleaseid
run: |
echo "RELEASE_TAG=$(git tag --sort=-taggerdate | head -1)" >> $GITHUB_ENV
echo "PREVIOUS_TAG=$(git tag --sort=-taggerdate | sed -n '2 p')" >> $GITHUB_ENV
- name: Publish Release
id: release
uses: release-drafter/release-drafter@v5
with:
version: ${{ env.RELEASE_TAG }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.ADMIN_GITHUB_TOKEN }}
- name: Merge release back into dev
uses: devmasx/[email protected]
with:
type: now
from_branch: main
target_branch: dev
github_token: ${{ secrets.ADMIN_GITHUB_TOKEN }}