-
Notifications
You must be signed in to change notification settings - Fork 316
175 lines (143 loc) · 8.38 KB
/
widgets-publish.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
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
name: Widgets - Version and Release
on:
workflow_dispatch:
inputs:
newversion:
type: choice
description: "Semantic Version Bump Type"
default: patch
options:
- patch
- minor
- major
defaults:
run:
working-directory: packages/widgets
concurrency:
group: "push-to-main"
jobs:
version_and_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Needed to push the tag and the commit on the main branch, otherwise we get:
# > Run git push --follow-tags
# remote: error: GH006: Protected branch update failed for refs/heads/main.
# remote: error: Changes must be made through a pull request. Required status check "lint" is expected.
token: ${{ secrets.BOT_ACCESS_TOKEN }}
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: |
packages/widgets/pnpm-lock.yaml
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
registry-url: "https://registry.npmjs.org"
- run: pnpm install
- run: git config --global user.name machineuser
- run: git config --global user.email infra+machineuser@huggingface.co
- run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
# Update package.json with the new version
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
git commit . -m "🔖 @huggingface/widgets $BUMPED_VERSION"
git tag "widgets-v$BUMPED_VERSION"
- name: Make sure that the latest version of @huggingface/tasks is consistent with the local version
run: |
LOCAL_TASKS_VERSION=$(node -p "require('./package.json').version")
REMOTE_TASKS_VERSION=$(npm view @huggingface/tasks version)
# If the versions are different, error
if [ "$LOCAL_TASKS_VERSION" != "$REMOTE_TASKS_VERSION" ]; then
echo "Error: The local @huggingface/tasks package version ($LOCAL_TASKS_VERSION) differs from the remote version ($REMOTE_TASKS_VERSION). Release halted."
exit 1
fi
npm pack @huggingface/tasks
mv huggingface-tasks-$LOCAL_TASKS_VERSION.tgz tasks-local.tgz
npm pack @huggingface/tasks@$REMOTE_TASKS_VERSION
mv huggingface-tasks-$REMOTE_TASKS_VERSION.tgz tasks-remote.tgz
# Compute checksum of local tar. We need to extract both tar since the remote compression might be different
tar -xf tasks-local.tgz
LOCAL_CHECKSUM=$(cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1)
echo "Local package checksum: $LOCAL_CHECKSUM"
rm -Rf package
tar -xf tasks-remote.tgz
REMOTE_CHECKSUM=$(cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1)
echo "Remote package checksum: $REMOTE_CHECKSUM"
rm -Rf package
if [ "$LOCAL_CHECKSUM" != "$REMOTE_CHECKSUM" ]; then
echo "Checksum Verification Failed: The local @huggingface/tasks package differs from the remote version. Release halted. Local Checksum: $LOCAL_CHECKSUM, Remote Checksum: $REMOTE_CHECKSUM"
exit 1
fi
echo "Checksum Verification Successful: The local and remote @huggingface/tasks packages are consistent. Proceeding with the @huggingface/widgets package release. Local Checksum: $LOCAL_CHECKSUM, Remote Checksum: $REMOTE_CHECKSUM."
working-directory: packages/tasks
- name: Make sure that the latest version of @huggingface/jinja is consistent with the local version
run: |
LOCAL_JINJA_VERSION=$(node -p "require('./package.json').version")
REMOTE_JINJA_VERSION=$(npm view @huggingface/jinja version)
# If the versions are different, error
if [ "$LOCAL_JINJA_VERSION" != "$REMOTE_JINJA_VERSION" ]; then
echo "Error: The local @huggingface/jinja package version ($LOCAL_JINJA_VERSION) differs from the remote version ($REMOTE_JINJA_VERSION). Release halted."
exit 1
fi
npm pack @huggingface/jinja
mv huggingface-jinja-$LOCAL_JINJA_VERSION.tgz jinja-local.tgz
npm pack @huggingface/jinja@$REMOTE_JINJA_VERSION
mv huggingface-jinja-$REMOTE_JINJA_VERSION.tgz jinja-remote.tgz
# Compute checksum of local tar. We need to extract both tar since the remote compression might be different
tar -xf jinja-local.tgz
LOCAL_CHECKSUM=$(cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1)
echo "Local package checksum: $LOCAL_CHECKSUM"
rm -Rf package
tar -xf jinja-remote.tgz
REMOTE_CHECKSUM=$(cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1)
echo "Remote package checksum: $REMOTE_CHECKSUM"
rm -Rf package
if [ "$LOCAL_CHECKSUM" != "$REMOTE_CHECKSUM" ]; then
echo "Checksum Verification Failed: The local @huggingface/jinja package differs from the remote version. Release halted. Local Checksum: $LOCAL_CHECKSUM, Remote Checksum: $REMOTE_CHECKSUM"
exit 1
fi
echo "Checksum Verification Successful: The local and remote @huggingface/jinja packages are consistent. Proceeding with the @huggingface/widgets package release. Local Checksum: $LOCAL_CHECKSUM, Remote Checksum: $REMOTE_CHECKSUM."
working-directory: packages/jinja
- name: Make sure that the latest version of @huggingface/inference is consistent with the local version
run: |
LOCAL_INFERENCE_VERSION=$(node -p "require('./package.json').version")
REMOTE_INFERENCE_VERSION=$(npm view @huggingface/inference version)
# If the versions are different, error
if [ "$LOCAL_INFERENCE_VERSION" != "$REMOTE_INFERENCE_VERSION" ]; then
echo "Error: The local @huggingface/inference package version ($LOCAL_INFERENCE_VERSION) differs from the remote version ($REMOTE_INFERENCE_VERSION). Release halted."
exit 1
fi
npm pack @huggingface/inference
mv huggingface-inference-$LOCAL_INFERENCE_VERSION.tgz inference-local.tgz
npm pack @huggingface/inference@$REMOTE_INFERENCE_VERSION
mv huggingface-inference-$REMOTE_INFERENCE_VERSION.tgz inference-remote.tgz
# Compute checksum of local tar. We need to extract both tar since the remote compression might be different
tar -xf inference-local.tgz
LOCAL_CHECKSUM=$(cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1)
echo "Local package checksum: $LOCAL_CHECKSUM"
rm -Rf package
tar -xf inference-remote.tgz
REMOTE_CHECKSUM=$(cd package && tar --mtime='1970-01-01' --mode=755 -cf - . | sha256sum | cut -d' ' -f1)
echo "Remote package checksum: $REMOTE_CHECKSUM"
rm -Rf package
if [ "$LOCAL_CHECKSUM" != "$REMOTE_CHECKSUM" ]; then
echo "Checksum Verification Failed: The local @huggingface/inference package differs from the remote version. Release halted. Local Checksum: $LOCAL_CHECKSUM, Remote Checksum: $REMOTE_CHECKSUM"
exit 1
fi
echo "Checksum Verification Successful: The local and remote @huggingface/inference packages are consistent. Proceeding with the @huggingface/widgets package release. Local Checksum: $LOCAL_CHECKSUM, Remote Checksum: $REMOTE_CHECKSUM."
working-directory: packages/inference
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git pull --rebase && git push --follow-tags
# hack - reuse actions/setup-node@v3 just to set a new registry
- uses: actions/setup-node@v3
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
- run: pnpm publish --no-git-checks .
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}