-
Notifications
You must be signed in to change notification settings - Fork 7
163 lines (139 loc) · 4.74 KB
/
Copy pathrelease.yml
File metadata and controls
163 lines (139 loc) · 4.74 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
use-npm:
description: Should npm packages be published?
type: boolean
default: true
use-homebrew:
description: Should the Homebrew tap be updated?
type: boolean
default: true
force-branch:
description: Allow releasing 'latest' from a non-main branch?
type: boolean
default: false
version:
description: The release version (e.g., v1.2.3)
required: false
permissions:
contents: write
env:
NOTO_VERSION: ${{ inputs.version || github.ref_name }}
jobs:
npm:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || inputs.use-npm == true }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: oven-sh/setup-bun@v2
- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: "https://registry.npmjs.org"
- run: bun install
working-directory: packages/cli
- name: Build
working-directory: packages/cli
run: bun run build
- name: Determine npm tag
id: determine_npm_tag
shell: bash
run: |
if [[ "${{ env.NOTO_VERSION }}" =~ -(next|canary|beta|rc) ]]; then
NPM_TAG=${BASH_REMATCH[1]}
elif [[ "${{ inputs.force-branch }}" == "true" ]]; then
echo "force-branch is enabled — skipping main branch check."
NPM_TAG="latest"
else
git fetch origin main
if git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
NPM_TAG="latest"
else
echo "The tagged commit is not on the main branch."
echo "::error ::Releases with the 'latest' npm tag must be on the main branch. Use 'force-branch' to override."
exit 1
fi
fi
echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
echo "Using npm tag: $NPM_TAG"
- name: Publish to npm
working-directory: packages/cli
run: bun publish --provenance --access public --tag ${{ steps.determine_npm_tag.outputs.npm_tag }}
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
homebrew:
runs-on: ubuntu-latest
needs: npm
if: >
always() &&
(needs.npm.result == 'success' || needs.npm.result == 'skipped') &&
(
github.event_name == 'push' ||
inputs.use-homebrew == true
) &&
!contains(github.ref, 'next') &&
!contains(github.ref, 'canary') &&
!contains(github.ref, 'beta') &&
!contains(github.ref, 'rc')
steps:
- name: Wait for npm package availability
if: needs.npm.result == 'success'
run: |
PACKAGE_NAME="@snelusha/noto"
VERSION="${{ env.NOTO_VERSION }}"
MAX_ATTEMPTS=30
SLEEP_TIME=10
echo "Waiting for $PACKAGE_NAME@$VERSION to be available on npm..."
for i in $(seq 1 $MAX_ATTEMPTS); do
echo "Attempt $i/$MAX_ATTEMPTS..."
if npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null; then
echo "Package is available!"
exit 0
fi
if [ $i -lt $MAX_ATTEMPTS ]; then
echo "Package not yet available, waiting ${SLEEP_TIME}s..."
sleep $SLEEP_TIME
fi
done
echo "Package did not become available after $((MAX_ATTEMPTS * SLEEP_TIME)) seconds"
exit 1
- name: Checkout homebrew-noto
uses: actions/checkout@v4
with:
repository: snelusha/homebrew-noto
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Setup GPG
id: gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
- name: Update Tap
run: ruby scripts/release.rb "${{ env.NOTO_VERSION }}"
- name: Commit Tap
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_options: --gpg-sign=${{ steps.gpg.outputs.keyid }}
commit_message: "chore: release ${{ env.NOTO_VERSION }}"
commit_user_name: "snelusha"
commit_user_email: "hello@snelusha.dev"
commit_author: "Sithija Nelusha Silva <hello@snelusha.dev>"