Skip to content

Commit

Permalink
release: fix version updating (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Aug 20, 2024
1 parent df151ca commit bbac06b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
- name: Update npm packages to latest version
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
working-directory: ./npm/wizer
run: npm install && npm version "${{ steps.tagname.outputs.val }}" --allow-same-version
run: npm install && node update.js "${{ steps.tagname.outputs.val }}"
- name: Setup npm auth
run: sudo npm config --global set '//registry.npmjs.org/:_authToken'='${NODE_AUTH_TOKEN}'
- name: Publish npm packages
Expand Down
20 changes: 9 additions & 11 deletions npm/wizer/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"name": "@bytecodealliance/wizer",
"version": "6.0.0",
"version": "VERSION",
"description": "The WebAssembly Pre-Initializer",
"private": true,
"type": "module",
"scripts": {
"version": "node ./update.js $npm_package_version"
},
"devDependencies": {
"decompress": "^4.2.1",
"decompress-unzip": "^4.0.1",
Expand All @@ -20,12 +18,12 @@
"wizer": "./wizer.js"
},
"optionalDependencies": {
"@bytecodealliance/wizer-darwin-arm64": "6.0.0",
"@bytecodealliance/wizer-darwin-x64": "6.0.0",
"@bytecodealliance/wizer-linux-x64": "6.0.0",
"@bytecodealliance/wizer-linux-arm64": "6.0.0",
"@bytecodealliance/wizer-linux-s390x": "6.0.0",
"@bytecodealliance/wizer-win32-x64": "6.0.0"
"@bytecodealliance/wizer-darwin-arm64": "VERSION",
"@bytecodealliance/wizer-darwin-x64": "VERSION",
"@bytecodealliance/wizer-linux-x64": "VERSION",
"@bytecodealliance/wizer-linux-arm64": "VERSION",
"@bytecodealliance/wizer-linux-s390x": "VERSION",
"@bytecodealliance/wizer-win32-x64": "VERSION"
},
"license": "Apache-2.0",
"repository": {
Expand All @@ -36,4 +34,4 @@
"url": "https://github.com/bytecodealliance/wizer/issues"
},
"homepage": "https://github.com/bytecodealliance/wizer#readme"
}
}
14 changes: 11 additions & 3 deletions npm/wizer/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@

import { fileURLToPath } from 'node:url';
import { dirname, join, parse } from 'node:path';
import { mkdir, writeFile } from "node:fs/promises";
import { mkdir, writeFile, readFile } from "node:fs/promises";
import decompress from 'decompress';
import decompressUnzip from 'decompress-unzip';
import decompressTar from 'decompress-tar';
import plzma from 'plzmasdk';
const __dirname = dirname(fileURLToPath(import.meta.url));
const input = process.argv.slice(2).at(0);
const tag = input ? `v${input}` : 'dev';
const version = process.argv.slice(2).at(0).trim();
const tag = version ? `v${version}` : 'dev';

const pjson = JSON.parse(await readFile('package.json'));
pjson.version = version;
delete pjson.private;
for (const dep of Object.keys(pjson.optionalDependencies)) {
pjson.optionalDependencies[dep] = version;
}
await writeFile('package.json', JSON.stringify(pjson, null, 2));

let packages = {
'wizer-darwin-arm64': {
Expand Down

0 comments on commit bbac06b

Please sign in to comment.