first commit #1
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
############################################################################### | |
# 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 }} | |
############################################################################### | |
# JOBS | |
############################################################################### | |
jobs: | |
######################################################################### | |
# CHECK LINUX BUILD | |
######################################################################### | |
check-build-ubuntu: | |
name: 🛠️ Check Build on Linux | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ env.GITHUB_TOKEN }} | |
- name: ⬇️ Checkout | |
uses: actions/checkout@v4 | |
- 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: 🏗 Build packages | |
run: | | |
pnpm build:packages # execute lint. tests and build | |
pnpm test:bin # execute special test for bin | |
- name: 📢 Notify if successful | |
run: echo "Build on Ubuntu completed successfully." | |
######################################################################### | |
# RELESE ON MACOS | |
######################################################################### | |
release: | |
name: 🚀 Release | |
runs-on: macos-latest | |
timeout-minutes: 10 | |
needs: check-build-ubuntu | |
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 | |
######################################################################### | |
# BUILD | |
######################################################################### | |
- name: 🏗 Build | |
run: pnpm build:packages | |
######################################################################### | |
# 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: | | |
docs_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | select(.name == "@bepp/docs") | .version') | |
core_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r 'map(select(.name == "@bepp/gh-action" or .name == "@bepp/core" or .name == "@bepp/bepp")) | .[0].version // empty' ) | |
core_version_major=${core_version%%.*} | |
echo Set changesets outputs | |
echo '${{ steps.changesets.outputs }}' | |
echo Set updated versions | |
echo "CORE=$core_version CORE_MAJOR=$core_version_major DOCS=$docs_version" | |
echo "core_version=$core_version" >> $GITHUB_OUTPUT | |
echo "docs_version=$docs_version" >> $GITHUB_OUTPUT | |
echo "core_version_major=$core_version_major" >> $GITHUB_OUTPUT | |
- name: 🌥 Deploy docs in Cloudflare pages if is @bepp/docs is updated | |
uses: cloudflare/pages-action@v1 | |
if: steps.updated.outputs.docs_version != '' | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
gitHubToken: ${{ env.GITHUB_TOKEN }} | |
branch: main | |
projectName: "bepp" | |
directory: 'packages/docs/dist' | |
wranglerVersion: '3' | |
- name: Release action if @bepp/core is updated | |
if: ${{ steps.updated.outputs.core_version != '' && steps.updated.outputs.core_version_major != '' }} | |
run: pnpm release-action '${{steps.updated.outputs.core_version}}' '${{steps.updated.outputs.core_version_major}}' | |
- name: Release binary if @bepp/core is updated | |
if: ${{ steps.updated.outputs.core_version != '' && steps.updated.outputs.core_version_major != '' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: "v${{ steps.updated.outputs.core_version }}" | |
draft: false | |
prerelease: false | |
allowUpdates: true | |
artifacts: "packages/bin/dist/zip/*" | |
omitBodyDuringUpdate: true | |
############################################################################### |