From bd6239b00c910ceee5c91777961e7a1617e9b0d6 Mon Sep 17 00:00:00 2001 From: tsamantanis Date: Mon, 12 Apr 2021 04:42:56 -0700 Subject: [PATCH] Create CD workflow for publishing to NPM registry --- .github/workflows.yml | 43 +++++++++++++++++++++++++++++++++++++++ example/package-lock.json | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .github/workflows.yml diff --git a/.github/workflows.yml b/.github/workflows.yml new file mode 100644 index 00000000..9e42202a --- /dev/null +++ b/.github/workflows.yml @@ -0,0 +1,43 @@ +// .github/workflows.yml +name: NPM publish CD workflow + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.release.target_commitish }} + # install Node.js + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12 + - run: yarn install + # set up git since we will later push to the repo + - run: git config --global user.name "tsamantanis" + - run: git config --global user.email "philip.tsamantanis@icloud.com" + # upgrade npm version in package.json to the tag used in the release. + - run: npm version ${{ github.event.release.tag_name }} + # build the project + - run: npm run build + # run tests just in case + - run: npm test + - run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}" + # publish to NPM -> there is one caveat, continue reading for the fix + - run: npm publish --tag ${{ github.event.release.target_commitish }} + # deploy example to GH pages + - run: npm deploy + env: + # Use a token to publish to NPM. See below for how to set it up + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + # push the version changes to GitHub + - run: git push + env: + # The secret is passed automatically. Nothing to configure. + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/example/package-lock.json b/example/package-lock.json index e495062f..dd154a70 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -24,7 +24,7 @@ }, "..": { "name": "@tsamantanis/react-glassmorphism", - "version": "1.0.2", + "version": "1.1.2", "license": "MIT", "dependencies": { "@types/styled-components": "^5.1.7",