Skip to content

Commit

Permalink
Add CI workflow to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Oct 8, 2024
1 parent 50ec24e commit 7610645
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,57 @@ 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
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 }}

0 comments on commit 7610645

Please sign in to comment.