Skip to content

Commit

Permalink
Merge pull request #2 from ChainSafe/nh/ci-publish
Browse files Browse the repository at this point in the history
Add CI workflow to publish
  • Loading branch information
nazarhussain authored Oct 8, 2024
2 parents 50ec24e + 6bbffea commit f221544
Showing 1 changed file with 53 additions and 3 deletions.
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 }}

0 comments on commit f221544

Please sign in to comment.