fix release issue #29
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
name: Release CI | |
on: | |
pull_request: | |
push: | |
branches: [master] | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'release: major|minor|patch' | |
required: true | |
default: patch | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
name: release | |
container: | |
image: synthetixio/docker-node:18.16-ubuntu | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
- name: Set pnpm cache directory | |
run: pnpm config set store-dir .pnpm-store | |
continue-on-error: true | |
- name: Setup cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.pnpm-store | |
node_modules | |
key: ${{ runner.os }}-pnpm-v1-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-v1- | |
continue-on-error: true | |
# fixes permission issues on docker | |
- name: Chown workspace | |
run: chown -R $(whoami) . | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --prefer-offline | |
- name: Set git config | |
run: | | |
git config user.name $GIT_USER | |
git config user.email $GIT_EMAIL | |
mkdir -p ~/.gnupg/ | |
printf $GPG_KEY | base64 -d > ~/.gnupg/private.key | |
gpg --import ~/.gnupg/private.key | |
git config commit.gpgsign true | |
git config user.signingkey $GIT_SIGNING_KEY | |
env: | |
GIT_USER: ${{ secrets.GIT_USER }} | |
GIT_EMAIL: ${{ secrets.GIT_EMAIL }} | |
GPG_KEY: ${{ secrets.GPG_KEY }} | |
GIT_SIGNING_KEY: ${{ secrets.GIT_SIGNING_KEY }} | |
- name: Set pnpm config | |
run: pnpm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}" | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Set current pnpm package version | |
id: extract-version | |
run: | | |
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]') | |
echo ::set-output name=current-version::$PACKAGE_VERSION | |
- name: Release ${{ github.event.inputs.version }} | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
git reset --hard | |
pnpm release:${{ github.event.inputs.version }} --ci | |
pnpm publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GIT_USER: ${{ secrets.GIT_USER }} | |
GIT_EMAIL: ${{ secrets.GIT_EMAIL }} | |
GPG_KEY: ${{ secrets.GPG_KEY }} | |
GIT_SIGNING_KEY: ${{ secrets.GIT_SIGNING_KEY }} | |
- name: Release patch:beta | |
run: | | |
git reset --hard | |
echo ${{ steps.extract-version.outputs.current-version }} | |
if echo ${{ steps.extract-version.outputs.current-version }} | grep -q "beta"; then | |
pnpm release --ci --preRelease | |
pnpm publish | |
else | |
pnpm release:patch --ci --preRelease=beta | |
pnpm publish | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GIT_USER: ${{ secrets.GIT_USER }} | |
GIT_EMAIL: ${{ secrets.GIT_EMAIL }} | |
GPG_KEY: ${{ secrets.GPG_KEY }} | |
GIT_SIGNING_KEY: ${{ secrets.GIT_SIGNING_KEY }} |