π ci(all): abstract ci #18
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
############################################################################### | |
# PUBLISH CORE IN NPM | |
############################################################################### | |
name: π Release | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
############################################################################### | |
# JOBS | |
############################################################################### | |
jobs: | |
update: | |
name: π Release | |
runs-on: ubuntu-latest | |
steps: | |
######################################################################### | |
# INIT | |
######################################################################### | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.12.1 | |
with: | |
access_token: ${{ env.GITHUB_TOKEN }} | |
- name: β¬οΈ Checkout | |
uses: actions/checkout@v4 | |
- 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: β¬οΈπ’ Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: β¬οΈπ₯‘ Install pnpm | |
uses: pnpm/action-setup@v3 | |
- name: β¬οΈπ¦ Install dependencies | |
run: | | |
pnpm install --no-frozen-lockfile | |
- name: β¬οΈπ Install Playwright Browsers | |
run: npx playwright install --with-deps | |
######################################################################### | |
# BUILD | |
######################################################################### | |
- name: π Build | |
run: pnpm build # CMD contains lint, test, and build | |
- name: πͺ Exit here if is pull request | |
if: github.event_name == 'pull_request' | |
run: | | |
gh run cancel ${{ github.run_id }} | |
gh run watch ${{ github.run_id }} | |
env: | |
GITHUB_TOKEN: ${{env.GITHUB_TOKEN }} | |
######################################################################### | |
######################################################################### | |
# UPDATE VERSIONS | |
######################################################################### | |
######################################################################### | |
- 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: | | |
docs_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | select(.name == "@s-8/docs") | .version') | |
exts_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | select(.name == "@s-8/exts") | .version') | |
app_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | select(.name == "@s-8/app") | .version') | |
core_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r 'map(select(.name == "@s-8/app" or .name == "@s-8/exts" or .name == "@s-8/core")) | .[0].version // empty' ) | |
echo Set updated versions | |
echo "CORE=$core_version APP=$app_version EXTS=$exts_version DOCS=$docs_version" | |
echo "core_version=$core_version" >> $GITHUB_OUTPUT | |
echo "docs_version=$docs_version" >> $GITHUB_OUTPUT | |
echo "exts_version=$exts_version" >> $GITHUB_OUTPUT | |
echo "app_version=$app_version" >> $GITHUB_OUTPUT | |
######################################################################### | |
# DOCS | |
######################################################################### | |
- name: πππΊβ‘οΈ Call to workflow for deploy Documentation | |
if: steps.updated.outputs.docs_version != '' | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: release-docs.yml | |
inputs: '{ "version": "${{ steps.updated.outputs.docs_version }}"}' | |
######################################################################### | |
# APP | |
######################################################################### | |
- name: π₯οΈππΊβ‘οΈ Call to workflow for create Github app releases | |
if: steps.updated.outputs.core_version != '' | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: release-apps.yml | |
inputs: '{ "version": "${{ steps.updated.outputs.core_version }}"}' | |
######################################################################### | |
# EXTS | |
######################################################################### | |
- name: π§©ππΊβ‘οΈ Call to workflow for create Github extension releases | |
if: steps.updated.outputs.core_version != '' | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: release-exts.yml | |
inputs: '{ "version": "${{ steps.updated.outputs.core_version }}"}' | |
############################################################################### |