-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from 1inch/auto-publish-pipeline
add workflow for publishing package to github and npm registries
- Loading branch information
Showing
3 changed files
with
61 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,72 @@ | ||
name: Release | ||
name: Publish package | ||
|
||
on: | ||
# manual trigger | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- v*.*.* | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
publish-to-npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code into workspace directory | ||
uses: actions/checkout@v2 | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v1 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
node-version: 18 | ||
registry-url: 'https://registry.npmjs.org' | ||
scope: ${{ github.repository_owner }} | ||
|
||
- name: Install yarn | ||
run: npm install --global yarn | ||
- name: Update package.json | ||
run: | | ||
TAG_NAME=${GITHUB_REF/refs\/tags\//} | ||
PACKAGE_VERSION=${TAG_NAME#v} | ||
echo "Updating package.json to version $PACKAGE_VERSION" | ||
cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json | ||
cat package.json | ||
- name: Install dependency | ||
run: yarn install | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- uses: JS-DevTools/npm-publish@v1 | ||
- name: Build | ||
run: yarn build | ||
|
||
- name: Publish | ||
run: yarn publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
|
||
publish-to-github: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v3 | ||
with: | ||
token: ${{ secrets.NPM_AUTH_TOKEN }} | ||
node-version: 18 | ||
registry-url: 'https://npm.pkg.github.com' | ||
scope: ${{ github.repository_owner }} | ||
|
||
- name: Update package.json | ||
run: | | ||
TAG_NAME=${GITHUB_REF/refs\/tags\//} | ||
PACKAGE_VERSION=${TAG_NAME#v} | ||
echo "Updating package.json to version $PACKAGE_VERSION" | ||
cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json | ||
cat package.json | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Publish | ||
run: yarn publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters