Skip to content

Commit

Permalink
Added auto-publishing to npmjs
Browse files Browse the repository at this point in the history
  • Loading branch information
dm3ch committed Jul 28, 2023
1 parent 8371a74 commit d347287
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/publish.yaml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,49 @@ on:
- v*.*.*

jobs:
publish:
publish-to-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
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.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:
node-version: 18
node-version: 12
registry-url: 'https://npm.pkg.github.com'
scope: ${{ github.repository_owner }}

Expand All @@ -26,7 +58,6 @@ jobs:
PACKAGE_VERSION=${TAG_NAME#v}
echo "Updating package.json to version $PACKAGE_VERSION"
cat <<< $(jq -r ".version=\"$PACKAGE_VERSION\"" package.json) > package.json
cat <<< $(jq -r ".name=\"@${{ github.repository }}\"" package.json) > package.json
cat package.json
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
./dist
./node_modules
dist
node_modules
.idea
coverage

0 comments on commit d347287

Please sign in to comment.