Skip to content

Commit

Permalink
add release & tests actions
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbCaudill committed Dec 11, 2023
1 parent d6c27ab commit 1213527
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release
on:
push:
tags: "*"
branches:
- main

permissions:
contents: write

jobs:
publish:
name: Publish package
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Install dependencies
id: deps
run: |
pnpm install
- name: Build release
id: build_release
run: |
pnpm build
- name: Run Tests
id: tests
run: |
pnpm test
- name: Publish Release
if: steps.tests.outcome == 'success'
run: |
if [ "$NODE_AUTH_TOKEN" = "" ]; then
echo "You need a NPM_TOKEN secret in order to publish."
false
fi
git config user.name github-actions
git config user.email [email protected]
echo //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} > .npmrc
EXTRA_ARGS=""
if [[ $VERSION == *"alpha."* ]] || [[ $VERSION == *"beta."* ]] || [[ $VERSION == *"rc."* ]]; then
echo "Is pre-release version"
EXTRA_ARGS="$EXTRA_ARGS --dist-tag next"
fi
npm publish ${VERSION} --force-publish $EXTRA_ARGS
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag release
if: steps.tests.outcome == 'success'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Tests
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review, review_requested]
branches:
- main
jobs:
run-tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Install and build
run: |
pnpm install
pnpm build
- name: Lint and run tests
run: |
pnpm lint
pnpm test

0 comments on commit 1213527

Please sign in to comment.