-
-
Notifications
You must be signed in to change notification settings - Fork 9
39 lines (32 loc) · 1.03 KB
/
tag.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
name: Tag
on:
push:
branches:
- main
permissions:
contents: write
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
sparse-checkout: package.json
- name: Check version
id: version
run: |
set -e -o pipefail
BEFORE_VERSION=$(git show "${{ github.event.before }}:package.json" | jq -r .version)
AFTER_VERSION=$(git show "${{ github.event.after }}:package.json" | jq -r .version)
if [ "$BEFORE_VERSION" != "$AFTER_VERSION" ]; then
echo "Version changed from $BEFORE_VERSION to $AFTER_VERSION"
echo "version=$AFTER_VERSION" >> "$GITHUB_OUTPUT"
fi
- name: Tag version
if: ${{ steps.version.outputs.version }}
run: |
set -e -o pipefail
git tag "${{ steps.version.outputs.version }}" "${{ github.event.after }}"
git push origin "${{ steps.version.outputs.version }}"