-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (69 loc) · 2.28 KB
/
changeset-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
---
name: Changeset Release
# yamllint disable rule:truthy
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions: read-all
jobs:
release:
# IMPORTANT: prevent this action from running on forks
if: github.repository == 'chizmw/json-on-the-clocktower'
permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
name: Changeset Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
token: ${{ secrets.CHANGESETS_TOKEN }}
# we want to know about all the tags
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Dependencies
run: yarn
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.CHANGESETS_TOKEN }}
with:
title: Release Changeset (bake CHANGELOG.md)
# we use ourself to get the information for the release
- name: Get Change Info
uses: chizmw/[email protected]
id: get-changelog-info
- name: Debug Tag Step
shell: bash
run: |
set -x
TAG_NAME=${{ steps.get-changelog-info.outputs.last-change-version-v }}
if git tag -l | grep -q "^${TAG_NAME}$"; then
echo "Tag ${TAG_NAME} already exists"
else
echo "Tag ${TAG_NAME} is new"
fi
- name: Push Tags
# https://github.com/changesets/action#custom-publishing
if: steps.changesets.outputs.hasChangesets == 'false'
shell: bash
run: |
TAG_NAME=${{ steps.get-changelog-info.outputs.last-change-version-v }}
# if the tag doesn't start with v, emit a warning
if [[ ! "${TAG_NAME}" =~ ^v.* ]]; then
echo "::warning::Tag ${TAG_NAME} does not start with v"
fi
# try not to recreate the tag
if git tag -l | grep -q "^${TAG_NAME}$"; then
echo "Tag ${TAG_NAME} already exists"
else
git tag ${TAG_NAME}
git push --tag
fi