diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f3e1c6c..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 @@ -180,4 +178,56 @@ 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 + - name: Publish + run: | + 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 + 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 + 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 }}