|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version number for the new release' |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + if: github.event_name == 'workflow_dispatch' |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Release new version |
| 16 | + run: | |
| 17 | + git config --global user.email "[email protected]" |
| 18 | + git config --global user.name "Alex Hultman" |
| 19 | + git clone --branch binaries --single-branch --depth 1 https://github.com/${{ github.repository }}.git |
| 20 | + cd uWebSockets.js |
| 21 | +
|
| 22 | + version="${{ github.event.inputs.version }}" |
| 23 | + binaries=($(find . -type f -name "*.node" -exec basename {} .node \;)) |
| 24 | +
|
| 25 | + declare -A abi_map=( |
| 26 | + ["108"]="18.x" |
| 27 | + ["115"]="20.x" |
| 28 | + ["120"]="21.x" |
| 29 | + ["127"]="22.x" |
| 30 | + ["131"]="23.x" |
| 31 | + ) |
| 32 | +
|
| 33 | + for binary in "${binaries[@]}"; do |
| 34 | + IFS='_' read -r os cpu abi <<< "${binary#uws_}" |
| 35 | + node_version="${abi_map[$abi]}" |
| 36 | +
|
| 37 | + echo '{ |
| 38 | + "name": "@uws/'"$binary"'", |
| 39 | + "version": "'"${version}"'", |
| 40 | + "main": "uws.js", |
| 41 | + "os": ["'"$os"'"], |
| 42 | + "cpu": ["'"$cpu"'"], |
| 43 | + "engines": { |
| 44 | + "node": "'"$node_version"'" |
| 45 | + } |
| 46 | + }' > package.json |
| 47 | +
|
| 48 | + echo 'module.exports = require("./'"$binary"'.node")' > uws.js |
| 49 | +
|
| 50 | + rm ESM_wrapper.mjs index.d.ts |
| 51 | + find . -name '*.node' ! -name "${binary}.node" -exec rm -f {} + |
| 52 | +
|
| 53 | + git checkout --detach |
| 54 | + git add -A |
| 55 | + git commit -m "Released @uws/$binary with version $version" |
| 56 | + git tag "v${version}-$binary" |
| 57 | + git push "https://x-access-token:${{ secrets.SECRET }}@github.com/${{ github.repository }}" "v${version}-$binary" |
| 58 | + git checkout binaries |
| 59 | + done |
| 60 | +
|
| 61 | + rm -rf *.node |
| 62 | +
|
| 63 | + deps="" |
| 64 | + for binary in "${binaries[@]}"; do |
| 65 | + deps+="\"@uws/$binary\": \"github:porsager/uWebSockets.js#v${version}-$binary\",\n " |
| 66 | + done |
| 67 | + deps=${deps%,*} |
| 68 | +
|
| 69 | + sed -i "s|\"optionalDependencies\": {}|\"optionalDependencies\": {\n $deps\n}|" package.json |
| 70 | + sed -i "s|\"version\": \"[^\"]*\"|\"version\": \"${version}\"|g" package.json |
| 71 | + sed -i "s|./uws_|@uws/uws_|g" uws.js |
| 72 | +
|
| 73 | + git checkout --detach |
| 74 | + git add package.json |
| 75 | + git add *.node |
| 76 | + git commit -m "Release $version" |
| 77 | +
|
| 78 | + git tag "v$version" |
| 79 | + git push "https://x-access-token:${{ secrets.SECRET }}@github.com/${{ github.repository }}" "v$version" |
0 commit comments