Merge pull request #161 from Phanindra-tw/master #13
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
name: Build and Release | ||
on: | ||
push: | ||
branches: | ||
- create-npm-package | ||
workflow_dispatch: | ||
jobs: | ||
build-release: | ||
name: Build the web app and make a zip release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout to repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Node.js 16.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "16.x" | ||
- name: Install dependencies | ||
run: yarn install | ||
- name: Run tests | ||
run: yarn test | ||
- name: Build the app | ||
run: yarn build-prod | ||
- id: versionCheck | ||
uses: EndBug/version-check@v2 | ||
with: | ||
file-url: https://unpkg.com/person-management-app@latest/package.json | ||
static-checking: localIsNew | ||
- name: Version guard | ||
if: steps.versionCheck.outputs.changed == 'false' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed('No version change detected. You should run `yarn bump:<patch|minor|major>` to bump the version') | ||
- name: Publish | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" | ||
yarn publish --new-version ${{ steps.versionCheck.outputs.version }} | ||
- id: versionCheck | ||
Check failure on line 48 in .github/workflows/build_publish.yaml GitHub Actions / Build and ReleaseInvalid workflow file
|
||
uses: EndBug/version-check@v2 | ||
with: | ||
file-url: https://unpkg.com/person-management-app@latest/package.json | ||
static-checking: localIsNew | ||
- name: Version guard | ||
if: steps.versionCheck.outputs.changed == 'false' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed('No version change detected. You should run `yarn bump:<patch|minor|major>` to bump the version') | ||
- name: Publish | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" | ||
yarn publish --new-version ${{ steps.versionCheck.outputs.version }} | ||
- name: Create Tag | ||
uses: actions/github-script@v5 | ||
env: | ||
VERSION: ${{ steps.versionCheck.outputs.version }} | ||
with: | ||
script: | | ||
github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: 'refs/tags/v' + process.env.VERSION, | ||
sha: context.sha | ||
}) |