-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.01 KB
/
changesets-publish.yml
File metadata and controls
77 lines (68 loc) · 2.01 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
name: Publish Changesets
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
get-version:
runs-on: ubuntu-slim
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v6
- name: Get version
id: get_version
run: echo "version=v$(cat version.txt)" >> $GITHUB_OUTPUT
check-should-publish:
runs-on: ubuntu-slim
needs: get-version
outputs:
has_outdated: ${{ steps.get_tags.outputs.has_outdated }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Need full history for git operations
- name: Get tags
id: get_tags
env:
TAG: ${{ needs.get-version.outputs.version }}
run: |
# Check if the revision exists already
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
echo "has_outdated=false" >> "$GITHUB_OUTPUT"
else
echo "has_outdated=true" >> "$GITHUB_OUTPUT"
fi
publish:
runs-on: ubuntu-latest
needs:
- get-version
- check-should-publish
if: needs.check-should-publish.outputs.has_outdated == 'true'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Need full history for git operations
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
- name: Publish tag
env:
TAG: ${{ needs.get-version.outputs.version }}
run: |
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.get-version.outputs.version }}
run: |
gh release create "$TAG" \
--title "$TAG" \
--generate-notes