From 7610645f4a9fe372af947f4a294252e258e43f07 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Tue, 8 Oct 2024 16:07:27 +0200 Subject: [PATCH 1/4] Add CI workflow to publish --- .github/workflows/CI.yml | 55 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f3e1c6c..83c2825 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -180,4 +180,57 @@ jobs: run: | set -e yarn test - \ No newline at end of file + + publish: + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + name: Publish + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: '22.4.x' + cache: yarn + - name: Create tag + id: tag + uses: butlerlogic/action-autotag@1.1.2 + with: + strategy: package + tag_prefix: "v" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Exit if no version change + if: steps.tag.outputs.tagcreated == 'no' + uses: actions/github-script@v3 + with: + script: core.setFailed('The package.json version did not change. Workflow will not create a release.') + - name: Install dependencies + run: yarn install + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + - name: Move artifacts + run: yarn artifacts + - name: List packages + run: ls -R ./npm + shell: bash + - name: Publish + run: | + yarn config set provenance true + if node -e "console.log(require('./package.json').version)" | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; + then + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + yarn publish --access public + elif node -e "console.log(require('./package.json').version)" | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; + then + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + yarn publish --tag next --access public + else + echo "Not a release, skipping publish" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From 8f78665ba8c2f56b54a8adb8bbb95787ea8bad5c Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Tue, 8 Oct 2024 16:09:09 +0200 Subject: [PATCH 2/4] Add white space --- .github/workflows/CI.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 83c2825..1ad106e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -233,4 +233,5 @@ jobs: fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + \ No newline at end of file From 5568eaea7de615324f3ac5cc4dc718122f376e26 Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Tue, 8 Oct 2024 16:09:53 +0200 Subject: [PATCH 3/4] Fix npm script name --- .github/workflows/CI.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1ad106e..3ba8e4e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -219,19 +219,18 @@ jobs: shell: bash - name: Publish run: | - yarn config set provenance true + npm config set provenance true if node -e "console.log(require('./package.json').version)" | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - yarn publish --access public + npm publish --access public elif node -e "console.log(require('./package.json').version)" | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+"; then echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - yarn publish --tag next --access public + npm publish --tag next --access public else echo "Not a release, skipping publish" fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - \ No newline at end of file From 6bbffea4d773a55d6b43d54fb48d2a633d90bb9c Mon Sep 17 00:00:00 2001 From: Nazar Hussain Date: Tue, 8 Oct 2024 16:15:22 +0200 Subject: [PATCH 4/4] Clean default values --- .github/workflows/CI.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3ba8e4e..49c3f31 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -67,7 +67,6 @@ jobs: version: 0.13.0 - name: Install packages run: sudo apt install libclang-dev llvm - shell: bash - name: Install cargo toolchains for windows if: ${{ contains(matrix.targets, 'msvc') }} uses: taiki-e/install-action@v2 @@ -84,7 +83,6 @@ jobs: tool: cargo-zigbuild - name: Install rupstup target run: rustup target add ${{ matrix.targets }} - shell: bash - run: yarn install - name: Build run: yarn build --target ${{ matrix.targets }} --cross-compile @@ -216,7 +214,6 @@ jobs: run: yarn artifacts - name: List packages run: ls -R ./npm - shell: bash - name: Publish run: | npm config set provenance true