-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (139 loc) · 4.49 KB
/
Copy pathrelease.yml
File metadata and controls
163 lines (139 loc) · 4.49 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:
bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
id-token: write
jobs:
ci:
name: Lint, Typecheck, Test
runs-on: macos-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 20
- run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Test
run: npx vitest --run
create-tag:
name: Bump & Tag
needs: ci
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump.outputs.version }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v6
with:
node-version: 20
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and tag
id: bump
run: |
npm version ${{ inputs.bump }} --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
git add package.json package-lock.json
git commit -m "chore: bump version to v${VERSION}"
git tag "v${VERSION}"
git push
git push --tags
publish:
name: Publish to npm
needs: [ci, create-tag]
if: always() && needs.ci.result == 'success' && (needs.create-tag.result == 'success' || needs.create-tag.result == 'skipped')
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ needs.create-tag.outputs.version && format('v{0}', needs.create-tag.outputs.version) || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false
- run: npm ci
- name: Build
run: npm run build
- name: Publish
run: npm publish --access public
github-release:
name: GitHub Release
needs: [publish, create-tag]
if: always() && needs.publish.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.create-tag.outputs.version && format('v{0}', needs.create-tag.outputs.version) || github.ref_name }}
generate_release_notes: true
update-homebrew:
name: Update Homebrew formula
needs: [publish, create-tag]
if: always() && needs.publish.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Get version
id: ver
run: |
VERSION="${{ needs.create-tag.outputs.version }}"
if [ -z "$VERSION" ]; then
VERSION="${GITHUB_REF_NAME#v}"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Download tarball and compute sha256
id: sha
run: |
URL="https://registry.npmjs.org/xcodebazelmcp/-/xcodebazelmcp-${{ steps.ver.outputs.version }}.tgz"
for i in 1 2 3 4 5; do
SHA=$(curl -sL "$URL" | shasum -a 256 | awk '{print $1}')
[ -n "$SHA" ] && break
sleep 10
done
echo "sha256=${SHA}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v5
with:
repository: DebugSwift/homebrew-xcodebazelmcp
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update formula
run: |
sed -i 's|url ".*"|url "https://registry.npmjs.org/xcodebazelmcp/-/xcodebazelmcp-${{ steps.ver.outputs.version }}.tgz"|' Formula/xcodebazelmcp.rb
sed -i 's|sha256 ".*"|sha256 "${{ steps.sha.outputs.sha256 }}"|' Formula/xcodebazelmcp.rb
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/xcodebazelmcp.rb
git commit -m "Update xcodebazelmcp to ${{ steps.ver.outputs.version }}"
git push