-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jocelyn Badgley (Twipped)
committed
Aug 30, 2022
1 parent
50baecf
commit a2a854a
Showing
1 changed file
with
60 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,46 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Test Latest and Publish | ||
name: "Release, Please!" | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
packages: write | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 17.x] | ||
node-version: [lts/-1, lts/*, latest] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Cache node modules | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
|
@@ -37,31 +53,51 @@ jobs: | |
- name: Test | ||
run: npm run test --if-present | ||
|
||
|
||
release: | ||
if: "contains(github.event.head_commit.message, '[release]') || github.event_name == 'workflow_dispatch'" | ||
please: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
outputs: | ||
released: ${{ steps.release.outputs.release_created }} | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
token: ${{secrets.GITHUB_TOKEN}} | ||
default-branch: main | ||
release-type: node | ||
|
||
- name: Echo results | ||
run: | | ||
RESULT=$(cat << EOM | ||
${{ toJSON(steps.release.outputs) }} | ||
EOM | ||
) | ||
echo "$RESULT" | ||
publish: | ||
needs: please | ||
if: ${{ needs.please.outputs.released }} | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
steps: | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v2 | ||
- name: Use Latest Node LTS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
node-version: lts/* | ||
cache: npm | ||
|
||
- name: Install Dependencies | ||
run: npm ci | ||
|
||
- name: Build Docs | ||
run: npm run docs | ||
- name: Build packages | ||
run: npm run build --if-present | ||
|
||
- name: Run Semantic Release | ||
run: npm run release | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GIT_AUTHOR_NAME: 'Jocelyn Badgley' | ||
GIT_AUTHOR_EMAIL: '[email protected]' | ||
GIT_COMMITTER_NAME: 'Release Bot' | ||
- name: Build docs | ||
run: npm run docs --if-present | ||
|
||
- name: NPM Publish | ||
run: npm publish |