Skip to content

🚀 Release packages #19

🚀 Release packages

🚀 Release packages #19

Workflow file for this run

###############################################################################
# RELEASE
###############################################################################
name: 🚀 Release packages
on:
# push:
# branches:
# - main
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
CORE_NAME: binarium
###############################################################################
# JOBS
###############################################################################
jobs:
release-lib:
name: 🚀 Release
runs-on: macos-latest
timeout-minutes: 10
steps:
#########################################################################
# INIT & INSTALL
#########################################################################
- name: ⬇️ Checkout
uses: actions/checkout@v4
- name: '📦 Setup jq'
uses: dcarbone/install-jq-action@v2
- name: 🟢 Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- name: 🥡 Install pnpm
uses: pnpm/action-setup@v3
- name: Check GitHub API Rate Limit
id: rate_limit
run: |
response=$(gh api rate_limit)
limit=$(echo $response | jq -r '.resources.core.limit')
remaining=$(echo $response | jq -r '.resources.core.remaining')
echo "GitHub API Rate Limit: $remaining/$limit"
if [ "$remaining" -lt 10 ]; then
exit 1
fi
env:
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: 🧩 Install dependencies
run: |
pnpm install --no-frozen-lockfile --ignore-scripts
#########################################################################
# BUILD
#########################################################################
- name: 🏗 Build
run: |
pnpm build
#########################################################################
# PUBLISH
#########################################################################
- name: 📣 Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
title: "chore(release): version packages 🦋"
publish: pnpm exec changeset publish
version: pnpm exec changeset version
commit: "chore(release): version packages 🦋 [skip ci]"
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
NPM_TOKEN: ${{ env.NPM_TOKEN }}
- name: Get updated versions if exists
id: updated
run: |
core_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r 'map(select(.name == "${{ env.CORE_NAME}}")) | .[0].version // empty' )
core_version_major=${core_version%%.*}
echo Set changesets outputs
echo '${{ steps.changesets.outputs }}'
echo Set updated versions
echo "core_version=$core_version" >> $GITHUB_OUTPUT
echo "core_major_version=$core_version_major" >> $GITHUB_OUTPUT
- name: ℹ️➡️ Check for changes in package.json
run: |
git fetch origin main
git diff --name-only HEAD origin/main | grep 'package.json' || echo "No changes in package.json"
continue-on-error: true
id: check_package_json
- name: ℹ️🐙😺➡️ Update repo info
if: steps.check_package_json.outputs.stdout != 'No changes in package.json'
run: pnpm . gh info update
continue-on-error: true
- name: 📚🐙😺➡️ Call to workflow for deploy Documentation
if: steps.updated.outputs.core_version != ''
uses: benc-uk/workflow-dispatch@v1
with:
workflow: release-docs.yml
inputs: '{ "version": "${{ steps.updated.outputs.core_version }}"}'
continue-on-error: true
- name: Release binary
if: ${{ steps.updated.outputs.core_version != '' }}
uses: ncipollo/release-action@v1
with:
tag: "v${{ steps.updated.outputs.core_version }}"
draft: false
prerelease: false
allowUpdates: true
omitBodyDuringUpdate: true
- name: Tag Repo
if: ${{ steps.updated.outputs.core_major_version != '' }}
uses: richardsimko/update-tag@v1
with:
tag_name: v${{ steps.updated.outputs.core_major_version}}
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
###############################################################################