-
Notifications
You must be signed in to change notification settings - Fork 78
141 lines (115 loc) · 4.47 KB
/
gh-release.yaml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# release package
name: Github Release
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
jobs:
build-binaries:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
TARBALL_TARGETS: linux-x64,linux-arm64,darwin-x64,darwin-arm64,win32-x64
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
aws-region: us-west-2
- uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: yarn
- run: yarn
- run: yarn build
- name: Set canary version
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: |
set -eou pipefail
set -x
REF="${{ github.head_ref }}"
if [[ -z "$REF" ]]; then
REF="${{ github.ref_name }}"
fi
# this will be the NPM dist-tag
GIT_ID=$(echo "${REF}" | sed 's/[^a-zA-Z0-9_-]/-/g')
# run 'lerna version' to get next prerelease
yarn -s lerna version prerelease --no-git-tag-version --preid $GIT_ID --ignore-scripts --exact --yes
# modify the prerelease to include the git commit hash
VERSION=$(jq -r .version lerna.json | sed -E "s/[^.]+$/$(git rev-parse --short HEAD)/")
# run 'lerna version' again to actually set the version with the commit hash
yarn -s lerna version $VERSION --no-git-tag-version --preid $GIT_ID --ignore-scripts --exact --yes
- run: npm install -g @jsdevtools/npm-publish
- name: npm publish
run: |
set -eou pipefail
set -x
yarn lerna run prepack
for packageDir in $(ls packages); do
npm-publish --token ${{ secrets.NPM_TOKEN }} --access public packages/${packageDir}/package.json
done
- name: Find packaged node version
id: find_packaged_node_version
working-directory: packages/cli
run: |
echo "NODE_VERSION=$(jq -r .oclif.update.node.version package.json)" >> "${GITHUB_OUTPUT}"
- uses: actions/cache@v4
id: cache-oclif-pack
name: Setup cache for oclif pack
with:
path: packages/cli/tmp/cache
key: preevy-oclif-pack-node-v${{ steps.find_packaged_node_version.outputs.NODE_VERSION }}
- name: Pack tarballs
working-directory: packages/cli
run: yarn oclif pack tarballs --parallel --no-xz --targets $TARBALL_TARGETS
- name: Upload tarballs
working-directory: packages/cli
run: yarn oclif upload tarballs --no-xz --targets $TARBALL_TARGETS
- name: Rename tarballs to remove git sha
working-directory: packages/cli/dist
run: |
git_sha="$(git rev-parse --short HEAD)"
for f in $(find . -maxdepth 1 -type f -name 'preevy-v*'); do
new_name="$(echo ${f} | sed 's/-'"${git_sha}"'//')"
echo "Renaming ${f} to ${new_name}"
mv "${f}" "${new_name}"
done
- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
draft: ${{ !startsWith(github.ref, 'refs/tags/') }}
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
files: |
packages/cli/dist/preevy-v*.tar.gz
- uses: actions/create-github-app-token@v1
if: startsWith(github.ref, 'refs/tags/')
id: app-token
with:
app-id: ${{ secrets.PREEVY_AUTOMATION_APP_ID }}
private-key: ${{ secrets.PREEVY_AUTOMATION_PRIVATE_KEY }}
owner: livecycle
repositories: 'preevy,homebrew-preevy'
- uses: actions/checkout@v4
name: Checkout homebrew repo
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ steps.app-token.outputs.token }}
repository: livecycle/homebrew-preevy
path: homebrew
- name: Update Homebrew formula
if: startsWith(github.ref, 'refs/tags/')
working-directory: packages/cli
run: |
version="$(jq -r .version package.json)"
node scripts/homebrew.mjs > ../../homebrew/Formula/preevy.rb
cd ../../homebrew
git config user.name "GitHub Actions"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/preevy.rb
git commit -m "Update Preevy formula for version ${version}"
git push