Skip to content
name: Build, Test, Release
on:
push:
branches: travelperk
pull_request:
branches: "*"
jobs:
# build_lint_test:
# name: Build, Lint, and Test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v3
# - name: Install Pnpm
# uses: pnpm/action-setup@v2.0.1
# with:
# version: 8.6.9
# - name: Setup Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 16.x
# cache: pnpm
# - name: Install dependencies
# run: pnpm install --frozen-lockfile
# - name: Lint
# run: pnpm run lint
# - name: Check format
# run: pnpm run check-format
# - name: Test
# run: pnpm run test
# - name: Build
# run: pnpm run build
release:
name: Release
# needs: build_lint_test
permissions:
contents: write # to push release tags
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/travelperk' }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Install Pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: 8.6.9
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Publish to NPM if there is no changeset
run: |
git fetch origin main
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
ls .npmrc
pnpm run changeset status
echo "Exit code: $?"
if [ $? -eq 1 ]; then
echo "No changeset found, publishing to NPM"
pnpm run release
git push --follow-tags origin travelperk
else
echo "Changeset found, skipping NPM publish"
fi
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}