-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (46 loc) · 1.69 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
name: Auto Release
on:
push:
branches:
- main # Only run on the main branch
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get current version from package.json
id: current_version
run: |
CURRENT_VERSION=$(jq -r '.version' package.json)
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Get previous version from Git
id: previous_version
run: |
PREV_VERSION=$(git show HEAD~1:package.json | jq -r '.version')
echo "PREV_VERSION=$PREV_VERSION" >> $GITHUB_ENV
- name: Check if version has changed
if: ${{ env.CURRENT_VERSION == env.PREV_VERSION }}
run: |
echo "Version has not changed. Exiting."
exit 0
- name: Create Tag
if: ${{ env.CURRENT_VERSION != env.PREV_VERSION }}
run: |
git tag -a "v${{ env.CURRENT_VERSION }}" -m "Release version ${{ env.CURRENT_VERSION }}"
git push origin "v${{ env.CURRENT_VERSION }}"
- name: Create GitHub Release
if: ${{ env.CURRENT_VERSION != env.PREV_VERSION }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.CURRENT_VERSION }}"
release_name: "Release v${{ env.CURRENT_VERSION }}"
body: "Automated release for version ${{ env.CURRENT_VERSION }}"
draft: false
prerelease: false