Skip to content

ci: configure setup stage outputs #3

ci: configure setup stage outputs

ci: configure setup stage outputs #3

Workflow file for this run

name: Release
on:
push:
branches:
- develop
- main
env:
CACHE_KEY: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }}
CACHE_PATH: ./*
jobs:
setup:
runs-on: ubuntu-latest
outputs:
node-version: ${{ steps.node-version.outputs.node-version }}
pnpm-version: ${{ steps.pnpm-version.outputs.pnpm-version }}
strategy:
matrix:
node-version:
- 20.9.0
pnpm-version:
- 8.10.0
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup pnpm v${{ matrix.pnpm-version }}
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm-version }}
- name: Setup node.js v${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm run build
- name: Cache setup
uses: actions/cache@v3
id: cache-setup
with:
key: ${{ env.CACHE_KEY }}
path: ${{ env.CACHE_PATH }}
- name: Set node-version
id: node-version
run: echo "node-version=${{ matrix.node-version }}" >> $GITHUB_OUTPUT
- name: Set pnpm-version
id: pnpm-version
run: echo "pnpm-version={{ matrix.pnpm-version }}" >> $GITHUB_OUTPUT
release:
needs: setup
runs-on: ubuntu-latest
name: release:${{ github.ref_name == 'main' && 'main' || 'develop' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ needs.setup.outputs.pnpm-version }}
- name: Setup node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ needs.setup.outputs.node-version }}
- name: Restore setup
uses: actions/cache@v3
id: restore-setup
with:
key: ${{ env.CACHE_KEY }}
path: ${{ env.CACHE_PATH }}
- name: Build
run: pnpm run build
- name: Setup npm registry
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> "$HOME/.npmrc"
- name: Canary release
if: github.ref_name == 'develop'
run: |
pnpm changeset version --snapshot next
pnpm changeset publish --tag next --no-git-tag
- name: Stable release
if: github.ref_name == 'main'
run: |
pnpm changeset version
pnpm changeset publish --no-git-tag
pnpm install
- name: Commit changes
if: github.ref_name == 'main'
run: |
git config user.name "GitHub Actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -- .npmrc
git add .
git diff-index --quiet HEAD || git commit -m "chore: release"
- name: Create git tags
if: github.ref_name == 'main'
run: |
pnpm changeset tag
- name: Push changes
if: github.ref_name == 'main'
run: |
git push origin main
git push origin main --tags
- name: Merge to develop
if: github.ref_name == 'main'
run: |
git checkout main
git pull
git checkout develop
git pull
git rebase main
git push