Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI workflow to publish #2

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 53 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -180,4 +178,56 @@ jobs:
run: |
set -e
yarn test


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 }}