Skip to content

Standard Publish

Standard Publish #86

name: Standard Publish
permissions: write-all
on:
workflow_dispatch:
inputs:
version:
description: 'Select Version To Bump'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
publish:
runs-on: ubuntu-latest
steps:
# Checkout repo
- name: Checkout Repo
id: checkout
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.PUBLISHER_SSH_KEY }}
# Install nix
- uses: DeterminateSystems/nix-installer-action@v4
- uses: DeterminateSystems/magic-nix-cache-action@v2
# Prepare and build sushi lib
- name: Build Sushi Lib
id: sushi
if: steps.checkout.outcome == 'success'
run: ./prep-sushi.sh
# Install node
- name: Install NodeJS v18
id: node
if: steps.sushi.outcome == 'success'
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
# Install deps
- name: Install Dependencies
id: install
if: steps.node.outcome == 'success'
run: npm install
# Configure Git
- name: Git Config
id: git
if: steps.install.outcome == 'success'
run: |
git config --global user.email "${{ secrets.CI_GIT_EMAIL }}"
git config --global user.name "${{ secrets.CI_GIT_USER }}"
# Set Release Version
- name: Bump Version
id: version
if: steps.git.outcome == 'success'
# bump the version without creating tag/commit and store the version in env
run: echo "NEW_VERSION=$(npm version ${{ inputs.version }} --no-git-tag-version)" >> $GITHUB_ENV
# Commit changes and tag
- name: Commit And Tag
id: commit
if: steps.version.outcome == 'success'
run: |
git add "package.json"
git add "package-lock.json"
git commit -m "Release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
# Push changes and tag
- name: Push Changes To Remote
id: push
if: steps.commit.outcome == 'success'
run: |
git push origin
git push -u origin ${{ env.NEW_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create gitHub release with built package archives
- name: Create GitHub Release
id: release
if: steps.push.outcome == 'success'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.NEW_VERSION }}
name: Release ${{ env.NEW_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}