-
Notifications
You must be signed in to change notification settings - Fork 57
63 lines (63 loc) · 2.45 KB
/
pre-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
name: prerelease
on:
push:
branches:
# releases/<package>/<tag>/<version>
- releases/*/*/*
jobs:
prerelease:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '*'
check-latest: true
registry-url: 'https://registry.npmjs.org'
- name: Extract tag, version and package
id: extract
run: |-
ref=${{ github.ref }}
branch=${ref:11}
info=${branch:9}
package_tag=${info%/*}
package=${package_tag%/*}
tag=${package_tag#*/}
version=${info##*/}
echo "package=${package}" >> $GITHUB_OUTPUT
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Log extracted information
run: |-
echo package=${{ steps.extract.outputs.package }}
echo tag=${{ steps.extract.outputs.tag }}
echo version=${{ steps.extract.outputs.version }}
- name: Setup git user
run: git config --global user.name github-actions
- name: Setup git email
run: git config --global user.email [email protected]
- name: Create fake .git in package subdirectory
# See https://github.com/npm/cli/issues/2010,https://github.com/npm/npm/issues/9111
run: mkdir packages/${{ steps.extract.outputs.package }}/.git
- name: Run npm version
run:
'npm version --workspace packages/${{ steps.extract.outputs.package }} ${{ steps.extract.outputs.version
}}-${{ steps.extract.outputs.tag }} -m "chore: release @netlify/${{ steps.extract.outputs.package }} ${{
steps.extract.outputs.version }}-${{ steps.extract.outputs.tag }}"'
- name: Prefix package to git tag
run: |-
old_git_tag=v${{ steps.extract.outputs.version}}-${{ steps.extract.outputs.tag }}
new_git_tag=${{ steps.extract.outputs.package }}-${old_git_tag}
git tag ${new_git_tag} ${old_git_tag}
git tag -d ${old_git_tag}
- name: Push changes
run: git push --follow-tags
- name: Install dependencies
run: npm install
- name: Build workspaces
run: npx lerna run build
- run: npm publish packages/${{ steps.extract.outputs.package }}/ --tag=${{ steps.extract.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}