Skip to content

Commit

Permalink
Merge pull request #15 from 1inch/auto-publish-pipeline
Browse files Browse the repository at this point in the history
add workflow for publishing package to github and npm registries
  • Loading branch information
nikmel2803 authored Jul 19, 2023
2 parents 69cf368 + bfcf949 commit 6de668f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 23 deletions.
79 changes: 61 additions & 18 deletions .github/workflows/release.yml
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 }}
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
"typescript": "^4.2.4"
},
"peerDependencies": {},
"publishConfig": {
"registry": "https://npm.pkg.github.com/1inch"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && yarn run typecheck"
Expand Down

0 comments on commit 6de668f

Please sign in to comment.