Skip to content

Commit 00b92d5

Browse files
authored
Merge pull request #13 from cawalch/ps/rr/release_v0_1_0
release v0.1.0
2 parents 289e857 + b990d49 commit 00b92d5

File tree

1 file changed

+54
-79
lines changed

1 file changed

+54
-79
lines changed

.github/workflows/CI.yml

Lines changed: 54 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ jobs:
7979
restore-keys: |
8080
${{ runner.os }}-npm-
8181
- uses: goto-bus-stop/setup-zig@v2
82-
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
82+
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
8383
with:
84-
version: 0.13.0
84+
version: 0.14.0
8585
- name: Setup toolchain
8686
run: ${{ matrix.settings.setup }}
8787
if: ${{ matrix.settings.setup }}
@@ -176,114 +176,89 @@ jobs:
176176
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim npm test
177177

178178
publish:
179-
name: Publish to npm
179+
name: Publish
180180
# Only run on tag pushes or release publish events
181-
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'release'
182181
needs:
183182
- test-macOS-binding
184183
- test-linux-x64-gnu-binding
185184
runs-on: ubuntu-latest
186185
steps:
187-
- name: Debug release info
188-
run: |
189-
echo "GitHub Ref: ${{ github.ref }}"
190-
echo "Event Name: ${{ github.event_name }}"
191-
echo "Release Tag: ${{ github.event.release.tag_name }}"
192-
193186
- uses: actions/checkout@v4
194-
with:
195-
fetch-depth: 0
196-
197187
- name: Setup node
198188
uses: actions/setup-node@v4
199189
with:
200190
node-version: 20
201-
registry-url: 'https://registry.npmjs.org'
202191
cache: 'npm'
203-
204192
- name: Install dependencies
205193
run: npm install
206-
207194
- name: Download all artifacts
208195
uses: actions/download-artifact@v4
209196
with:
210197
path: artifacts
211-
212-
- name: Debug artifact structure
213-
run: |
214-
echo "Artifact directory structure:"
215-
find artifacts -type f | sort
216-
217198
- name: Create npm directory structure
218199
run: |
219200
# Create npm directory structure
220201
mkdir -p npm/darwin-x64
221202
mkdir -p npm/darwin-arm64
222203
mkdir -p npm/linux-x64-gnu
223-
224-
- name: Move artifacts to root
225-
run: |
226-
# Copy artifacts to root for GitHub release
227-
find artifacts -name "*.node" -type f -exec cp {} . \;
228-
229-
- name: Run artifacts script
204+
- name: Move artifacts
230205
run: npm run artifacts
231-
232206
- name: List packages
207+
run: ls -R ./npm
208+
shell: bash
209+
- name: Create platform package.json files
233210
run: |
234-
echo "Files in npm directories:"
235-
ls -la npm/ || echo "No npm directory"
236-
ls -la npm/*/ || echo "No platform subdirectories"
237-
238-
echo "Files in root:"
239-
ls -la *.node || echo "No .node files in root"
240-
241-
- name: Verify package version matches release
242-
id: verify_version
243-
run: |
244-
# Determine version from tag or release
245-
if [ "${{ github.event_name }}" == "release" ]; then
246-
TAG_NAME="${{ github.event.release.tag_name }}"
247-
else
248-
TAG_NAME="${{ github.ref_name }}"
249-
fi
211+
# Determine version from commit message or package.json
212+
VERSION=$(node -p "require('./package.json').version")
250213
251-
# Remove 'v' prefix if present
252-
RELEASE_VERSION="${TAG_NAME#v}"
214+
# Create package.json files in each platform directory
215+
cat > npm/darwin-x64/package.json << EOF
216+
{
217+
"name": "${PACKAGE_NAME}-darwin-x64",
218+
"version": "${VERSION}",
219+
"os": ["darwin"],
220+
"cpu": ["x64"],
221+
"main": "${APP_NAME}.node",
222+
"files": ["${APP_NAME}.node"]
223+
}
224+
EOF
253225
254-
# Get current version from package.json
255-
PACKAGE_VERSION=$(node -p "require('./package.json').version")
226+
cat > npm/darwin-arm64/package.json << EOF
227+
{
228+
"name": "${PACKAGE_NAME}-darwin-arm64",
229+
"version": "${VERSION}",
230+
"os": ["darwin"],
231+
"cpu": ["arm64"],
232+
"main": "${APP_NAME}.node",
233+
"files": ["${APP_NAME}.node"]
234+
}
235+
EOF
256236
257-
echo "Release version: $RELEASE_VERSION"
258-
echo "Package version: $PACKAGE_VERSION"
259-
260-
# Skip version update if already correct
261-
if [ "$RELEASE_VERSION" = "$PACKAGE_VERSION" ]; then
262-
echo "Version already matches, no update needed"
237+
cat > npm/linux-x64-gnu/package.json << EOF
238+
{
239+
"name": "${PACKAGE_NAME}-linux-x64-gnu",
240+
"version": "${VERSION}",
241+
"os": ["linux"],
242+
"cpu": ["x64"],
243+
"main": "${APP_NAME}.node",
244+
"files": ["${APP_NAME}.node"]
245+
}
246+
EOF
247+
- name: Publish
248+
run: |
249+
npm config set provenance true
250+
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
251+
then
252+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
253+
npm publish --access public
254+
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
255+
then
256+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
257+
npm publish --tag next --access public
263258
else
264-
echo "Updating version from $PACKAGE_VERSION to $RELEASE_VERSION"
265-
npm version $RELEASE_VERSION --no-git-tag-version
266-
267-
# Also update version in platform-specific package.json files
268-
for dir in npm/darwin-x64 npm/darwin-arm64 npm/linux-x64-gnu; do
269-
if [ -f "$dir/package.json" ]; then
270-
node -e "const pkg = require('./$dir/package.json'); pkg.version = '$RELEASE_VERSION'; require('fs').writeFileSync('./$dir/package.json', JSON.stringify(pkg, null, 2));"
271-
fi
272-
done
259+
echo "Not a release, skipping publish"
273260
fi
274-
275-
- name: Publish to npm
276-
run: npm publish --access public
277261
env:
278-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
279-
280-
- name: Update release with binaries
281-
uses: softprops/action-gh-release@v1
282-
with:
283-
files: |
284-
*.node
285-
# If triggered by a tag push, create a release
286-
tag_name: ${{ github.ref_name }}
287-
# Only generate release notes if one doesn't exist
288-
generate_release_notes: ${{ github.event_name != 'release' }}
262+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
263+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
289264

0 commit comments

Comments
 (0)