-
-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (51 loc) · 1.63 KB
/
Copy pathrelease.yml
File metadata and controls
59 lines (51 loc) · 1.63 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
# Creates an annotated tag on pushes to master where package.json version
# has changed. Pairs with the manual release workflow for auto-tagging.
#
# Adapted from @ogis/icons publish.yml pattern.
name: Release
on:
push:
branches:
- master
permissions:
contents: write
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if version changed
id: version
run: |
if git diff HEAD~1 HEAD -- package.json | grep -q '"version"'; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Extract version from package.json
id: extract
if: steps.version.outputs.changed == 'true'
run: |
VERSION=v$(node -p "require('./package.json').version")
echo "tag=$VERSION" >> $GITHUB_OUTPUT
- name: Create annotated tag
id: tag
if: steps.version.outputs.changed == 'true'
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
TAG="${{ steps.extract.outputs.tag }}"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Create GitHub Release
if: steps.version.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.tag.outputs.tag }}" \
--title "${{ steps.tag.outputs.tag }}" \
--generate-notes \
--verify-tag