Skip to content

Commit b6be69a

Browse files
committed
.github/workflows: Drop redundant roundtrips and two-stage tag.
We were releasing to GitHub and then needed a second tag to download them again and publish to npm, being careful to let the first one complete first. We can simply publish them when we make them. Way fewer roundtrips and renames, and no timing delays.
1 parent 4d4f1e6 commit b6be69a

6 files changed

Lines changed: 25 additions & 519 deletions

File tree

.github/workflows/npm-firmware.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111

1212
permissions:
1313
contents: write
14+
id-token: write
1415

1516
jobs:
1617
upload_release:
@@ -44,7 +45,13 @@ jobs:
4445
poetry run make $MAKEOPTS -C bricks/nxt
4546
poetry run make $MAKEOPTS -C bricks/ev3
4647
- name: Get tag
47-
run: echo "GITHUB_TAG=${GITHUB_REF#*refs/tags/}" >> $GITHUB_ENV
48+
run: |
49+
TAG="${GITHUB_REF#*refs/tags/}"
50+
NPM_VERSION=$(echo "${TAG#v}" | sed 's/\([0-9]\)a\([0-9]\)/\1-alpha.\2/;s/\([0-9]\)b\([0-9]\)/\1-beta.\2/;s/\([0-9]\)rc\([0-9]\)/\1-rc.\2/')
51+
NPM_TAG=$(echo "$NPM_VERSION" | grep -q '-' && echo 'next' || echo 'latest')
52+
echo "GITHUB_TAG=$TAG" >> $GITHUB_ENV
53+
echo "NPM_VERSION=$NPM_VERSION" >> $GITHUB_ENV
54+
echo "NPM_TAG=$NPM_TAG" >> $GITHUB_ENV
4855
- name: Create Release and Upload Assets
4956
env:
5057
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -56,8 +63,10 @@ jobs:
5663
PRERELEASE_FLAG=""
5764
fi
5865
HUBS="movehub cityhub technichub primehub essentialhub nxt ev3"
66+
mkdir -p npm/firmware/build
5967
for HUB in $HUBS; do
6068
NEW_FILENAME="./bricks/$HUB/build/pybricks-$HUB-${{ env.GITHUB_TAG }}.zip"
69+
cp "./bricks/$HUB/build/firmware.zip" "npm/firmware/build/$HUB.zip"
6170
mv "./bricks/$HUB/build/firmware.zip" "$NEW_FILENAME"
6271
ASSETS="$ASSETS $NEW_FILENAME"
6372
done
@@ -67,3 +76,16 @@ jobs:
6776
-F CHANGELOG.md \
6877
$PRERELEASE_FLAG \
6978
$ASSETS
79+
- name: Set up Node.js
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: '24'
83+
registry-url: 'https://registry.npmjs.org'
84+
- name: Publish npm firmware package
85+
working-directory: npm/firmware
86+
run: |
87+
npm version --no-git-tag-version "${{ env.NPM_VERSION }}"
88+
echo "export const FIRMWARE_TAG = '${{ env.GITHUB_TAG }}';" > version.ts
89+
yarn install
90+
npx tsc
91+
npm publish --tag "${{ env.NPM_TAG }}"

npm/firmware/.yarnrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)