From 300a9318bd92900c4a5ff4ba9111849ca73a392b Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Wed, 17 Aug 2022 05:55:39 +0000 Subject: [PATCH] chore: setup workflow_dispatch --- .github/workflows/main.yml | 49 ++++++++++++++++++++++++++++---------- .releaserc.json | 4 ++++ 2 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 .releaserc.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c5db326..b7368d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,13 @@ -name: CI +name: CI & Release on: - - push - - pull_request + push: + workflow_dispatch: + inputs: + release: + description: 'Release new version' + required: true + default: false + type: boolean jobs: test: runs-on: ${{ matrix.platform }} @@ -9,19 +15,36 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - node-version: - - 16 + platform: [ubuntu-latest, macos-latest] + node-version: [lts/*, current] steps: - - name: Set git to use LF - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm run lint - run: npm run build - #- run: npm test + - run: npm test + + release: + name: 'Semantic release' + needs: test + runs-on: ubuntu-latest + if: inputs.release == true + steps: + - uses: actions/checkout@v3 + with: + # Need to fetch entire commit history to + # analyze every commit since last release + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: 'npm' + - run: npm install + # Branches that will release new versions are defined in .releaserc.json + - run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..6e8eb65 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,4 @@ +{ + "extends": "@sanity/semantic-release-preset", + "branches": ["master"] +}