-
-
Notifications
You must be signed in to change notification settings - Fork 2
219 lines (190 loc) · 7.36 KB
/
Copy pathrelease.yml
File metadata and controls
219 lines (190 loc) · 7.36 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Release
on:
push:
branches: [main]
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
id-token: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
paths_released: ${{ steps.release.outputs.paths_released }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Release Please
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
config-file: .release-please-config.json
manifest-file: .release-please-manifest.json
publish-npm:
needs: release-please
if: needs.release-please.outputs.releases_created == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check for npm packages
id: check-npm
run: |
PATHS='${{ needs.release-please.outputs.paths_released }}'
HAS_NPM=$(echo "$PATHS" | jq -r '[.[] | select(endswith("-dart") | not)] | length > 0')
echo "has_npm_packages=$HAS_NPM" >> $GITHUB_OUTPUT
- name: Setup Bun
if: steps.check-npm.outputs.has_npm_packages == 'true'
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Setup Node.js
if: steps.check-npm.outputs.has_npm_packages == 'true'
uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
if: steps.check-npm.outputs.has_npm_packages == 'true'
run: bun install --frozen-lockfile
- name: Build all packages
if: steps.check-npm.outputs.has_npm_packages == 'true'
run: bun run --filter './packages/*' build
- name: Publish changed packages
if: steps.check-npm.outputs.has_npm_packages == 'true'
run: |
PATHS='${{ needs.release-please.outputs.paths_released }}'
for pkg in $(echo "$PATHS" | jq -r '.[]'); do
if [[ "$pkg" == packages/* ]] && [[ "$pkg" != *"-dart" ]]; then
echo "Publishing $pkg..."
cd "$pkg"
bun publish --access public
cd -
fi
done
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-dart:
needs: release-please
if: needs.release-please.outputs.releases_created == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Dart packages to publish
id: dart-packages
run: |
PATHS='${{ needs.release-please.outputs.paths_released }}'
DART_PACKAGES=$(echo "$PATHS" | jq -c '[.[] | select(endswith("-dart"))]')
COUNT=$(echo "$DART_PACKAGES" | jq 'length')
echo "packages=$DART_PACKAGES" >> $GITHUB_OUTPUT
echo "count=$COUNT" >> $GITHUB_OUTPUT
- name: Setup Flutter
if: steps.dart-packages.outputs.count != '0'
uses: subosito/flutter-action@v2
with:
channel: stable
- name: Setup pub.dev credentials
if: steps.dart-packages.outputs.count != '0'
run: |
mkdir -p $XDG_CONFIG_HOME/dart
echo '${{ secrets.PUB_CREDENTIALS }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"
- name: Publish Dart packages
if: steps.dart-packages.outputs.count != '0'
run: |
PACKAGES='${{ steps.dart-packages.outputs.packages }}'
for pkg in $(echo "$PACKAGES" | jq -r '.[]'); do
echo "Publishing $pkg..."
cd "$pkg"
flutter pub get
dart analyze
flutter pub publish --force
cd -
done
publish-zotero:
needs: release-please
if: needs.release-please.outputs.releases_created == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for Zotero packages
id: check-zotero
run: |
PATHS='${{ needs.release-please.outputs.paths_released }}'
HAS_ZOTERO=$(echo "$PATHS" | jq -r '[.[] | select(. == "packages/zotero-plugin-uts")] | length > 0')
echo "has_zotero_package=$HAS_ZOTERO" >> $GITHUB_OUTPUT
- name: Setup Bun
if: steps.check-zotero.outputs.has_zotero_package == 'true'
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
if: steps.check-zotero.outputs.has_zotero_package == 'true'
run: bun install --frozen-lockfile
- name: Get new version
id: version
if: steps.check-zotero.outputs.has_zotero_package == 'true'
run: |
VERSION=$(node -p "require('./packages/zotero-plugin-uts/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=zotero-plugin-uts@$VERSION" >> $GITHUB_OUTPUT
- name: Build .xpi file
if: steps.check-zotero.outputs.has_zotero_package == 'true'
run: |
cd packages/zotero-plugin-uts
bun run build:xpi
- name: Update updates.json
if: steps.check-zotero.outputs.has_zotero_package == 'true'
run: |
VERSION='${{ steps.version.outputs.version }}'
TAG='${{ steps.version.outputs.tag }}'
UPDATE_FILE='packages/zotero-plugin-uts/updates.json'
# Update updates.json using jq
cat "$UPDATE_FILE" | jq --arg v "$VERSION" --arg t "$TAG" '
.addons["uts-citation@gracefullight.dev"].updates |= . + [{
"version": $v,
"update_link": ("https://github.com/gracefullight/pkgs/releases/download/\($t)/zotero-plugin-uts@\($v).xpi"),
"applications": {
"zotero": {
"strict_min_version": "7.0",
"strict_max_version": "8.*"
}
}
}]
' > "$UPDATE_FILE.tmp" && mv "$UPDATE_FILE.tmp" "$UPDATE_FILE"
- name: Commit updates.json
if: steps.check-zotero.outputs.has_zotero_package == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add packages/zotero-plugin-uts/updates.json
git commit -m "chore: update updates.json for ${{ steps.version.outputs.version }}"
- name: Push updates.json
if: steps.check-zotero.outputs.has_zotero_package == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
- name: Upload XPI as artifact
if: steps.check-zotero.outputs.has_zotero_package == 'true'
uses: actions/upload-artifact@v4
with:
name: zotero-plugin-uts-xpi
path: packages/zotero-plugin-uts/zotero-plugin-uts@*.xpi
retention-days: 30
- name: Upload .xpi to Release
if: steps.check-zotero.outputs.has_zotero_package == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
files: packages/zotero-plugin-uts/zotero-plugin-uts@*.xpi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}