Skip to content

Next Release

Next Release #83

Workflow file for this run

name: Next Release
on:
workflow_dispatch:
inputs:
prNumber:
description: Number of PR
required: false
ref:
description: The branch that is being deployed.
required: false
default: next
repository:
description: The {owner}/{repository} that is being deployed.
required: false
default: Garlic-Team/gcommands
jobs:
release:
name: publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.event.inputs.repository || 'Garlic-Team/GCommands' }}
ref: ${{ github.event.inputs.ref || 'next' }}
- name: Install Node v20
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build a package
run: pnpm run build
- name: Deprecate old versions
run: |
if [ '${{ github.event.inputs.prNumber }}' == '' ]; then
npm deprecate gcommands@"~$(jq --raw-output '.version' package.json)-next" "This version is no longer supported. Please upgrade to the latest version using npm i gcommands@latest" || true
else
npm deprecate gcommands@"~$(jq --raw-output '.version' package.json)-pr-${{ github.event.inputs.prNumber }}" "This version is no longer supported. Please upgrade to the latest version using npm i gcommands@latest" || true
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Publish a NPM package
run: |
TAGINVER=$([[ '${{ github.event.inputs.prNumber }}' == '' ]] && echo '-next' || echo '-pr-${{ github.event.inputs.prNumber }}')
TAG=$([[ '${{ github.event.inputs.prNumber }}' == '' ]] && echo 'next' || echo 'pr-${{ github.event.inputs.prNumber }}')
npm version --git-tag-version=false $(jq --raw-output '.version' package.json)${TAG}.$(date +%s)
pnpm publish --tag ${TAG} || true
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}