Repository navigation
126 lines (126 loc) · 4.21 KB
/
Copy pathrelease-v2.yml
File metadata and controls
126 lines (126 loc) · 4.21 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: "Release v2 NPM Package"
on:
workflow_dispatch:
inputs:
bump:
description: |
How to determine the release version.
custom: use the version from the "tag" input.
major/minor/patch: yarn bumps the current version automatically.
type: choice
required: false
default: custom
options:
- custom
- major
- minor
- patch
tag:
description: |
Enter the version for the release tag.
Must be larger than last tag.
Use patch (2.0.x) for bug fixes.
Use minor (2.x.0) for new actions.
Only used when "bump" is custom.
type: string
required: false
dry_run:
description: |
Run the full release pipeline without side effects:
nothing is pushed and nothing is published.
type: boolean
required: false
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
merge-to-v2-branch:
name: Create release by rebasing master to v2 and create a new tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v7
with:
node-version: '26'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- run: yarn install
- name: Resolve release version
id: resolve
env:
BUMP: ${{ inputs.bump }}
TAG: ${{ inputs.tag }}
run: |
case "$BUMP" in
major|minor|patch)
echo "requested=$BUMP" >> "$GITHUB_OUTPUT"
;;
custom)
if [ -z "$TAG" ]; then
echo "::error::bump is 'custom' but the 'tag' input is empty" ; exit 1
fi
if ! [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::'tag' must be a semver like 2.1.3, got '$TAG'" ; exit 1
fi
echo "requested=$TAG" >> "$GITHUB_OUTPUT"
;;
*)
echo "::error::unknown bump '$BUMP'" ; exit 1
;;
esac
- name: Set git name, mail and origin
run: |
git config --global user.name "Josef Fröhle"
git config --global user.email "github@josef-froehle.de"
git remote set-url origin https://${{ secrets.BOT_PIPELINE_TOKEN }}@github.com/${{ github.repository }}
- name: Checkout v2 branch and merge
run: |
git checkout v2 2>/dev/null || git checkout -b v2 origin/master
git merge --ff-only master
- name: Generate new tag
id: release
env:
REQUESTED: ${{ steps.resolve.outputs.requested }}
run: |
yarn run build
CURRENT="$(node -p "require('./package.json').version")"
if [ "$CURRENT" != "$REQUESTED" ]; then
yarn version "$REQUESTED" --immediate
else
echo "package.json is already at $CURRENT - skipping version bump"
fi
yarn run changelog
yarn run documentation
VERSION="$(node -p "require('./package.json').version")"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
git add -A
git commit -m "v$VERSION"
git tag -a "v$VERSION" -m "v$VERSION"
- name: Push tag and branch, sync master, publish docs
if: ${{ !inputs.dry_run }}
run: |
git push -u origin v2
git push --tags
git checkout master
git merge --ff-only v2
git push
git subtree split --prefix docs -b gh-pages
git push -f origin gh-pages:gh-pages
- name: Publish to npm
if: ${{ !inputs.dry_run }}
run: yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Pack package without publishing (dry run)
if: ${{ inputs.dry_run }}
run: yarn npm publish --dry-run
- name: Upload generated changelog (dry run)
if: ${{ inputs.dry_run }}
uses: actions/upload-artifact@v7
with:
name: HISTORY.md
path: HISTORY.md