Skip to content

chore(ci): add workflow for creating rc #45

chore(ci): add workflow for creating rc

chore(ci): add workflow for creating rc #45

Workflow file for this run

name: Deploy
on:
push:
branches:
- master
- feature-*
- release-*
- hotfix-*
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- name: Node
uses: actions/setup-node@v3
- name: Cache
id: cache-nodemodules
uses: actions/cache@v3
with:
path: node_modules
key: packages-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
packages-
- name: Install Pnpm
run: npm i -g pnpm
- name: Pnpm Install
run: pnpm install
- name: Lint
run: pnpm lint
- name: Build
run: pnpm build
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: ./
should-release:
needs: [build]
strategy:
fail-fast: false
matrix:
app: [antd, layout, tailwind]
name: Should Release
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Node
uses: actions/setup-node@v3
- name: Deps
run: npm i -g semver
- name: Run should-release
shell: bash
run: scripts/should-release.sh packages/${{ matrix.app }}/package.json
- name: Current Version
id: current-version
run: echo '${{ matrix.app }}_current_version='$(node -p -e "require('./packages/${{ matrix.app }}/package.json').version") >> $GITHUB_OUTPUT
- name: Check Skip Release
id: skip-release
run: echo '${{ matrix.app }}_skip='$(cat .skip-release) >> $GITHUB_OUTPUT
outputs:
antd_skip: ${{ steps.skip-release.outputs.antd_skip }}
antd_current_version: ${{ steps.current-version.outputs.antd_current_version }}
tailwind_skip: ${{ steps.skip-release.outputs.tailwind_skip }}
tailwind_current_version: ${{ steps.current-version.outputs.tailwind_current_version }}
layout_skip: ${{ steps.skip-release.outputs.layout_skip }}
layout_current_version: ${{ steps.current-version.outputs.layout_current_version }}
release-candidate:
needs: [should-release]
if: github.ref != 'refs/heads/master' && (startsWith(github.ref, 'refs/heads/feature-') || startsWith(github.ref, 'refs/heads/hotfix-') || startsWith(github.ref, 'refs/heads/release-'))
strategy:
fail-fast: false
matrix:
app: [antd, layout, tailwind]
name: Release Candidate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
path: ./
- name: Update package.json with RC version
if: ${{ needs.should-release.outputs[format('{0}_skip', matrix.app)] != 'true' }}
run: scripts/rc.sh packages/${{ matrix.app }}/package.json
- name: Upload Updated Artifact
if: ${{ needs.should-release.outputs[format('{0}_skip', matrix.app)] != 'true' }}
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: ./
overwrite: true
publish:
needs: [should-release, release-candidate]
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/hotfix-') || startsWith(github.ref, 'refs/heads/release-')
strategy:
fail-fast: false
matrix:
app: [antd, layout, tailwind]
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: npm-publish
if: ${{ needs.should-release.outputs[format('{0}_skip', matrix.app)] != 'true' }}
uses: ./.github/actions/npm-publish
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ needs.should-release.outputs[format('{0}_current_version', matrix.app)] }}
npm-auth-token: ${{ secrets.NPM_AUTH_TOKEN }}
path: ./packages/${{ matrix.app }}
create-tag:
needs: [publish]
if: github.ref == 'refs/heads/master'
name: Create Tag
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Semver
id: semver
uses: luanlmd/semver-composite-action@v1.0.0
with:
repo-path: ${{ github.workspace }}
- name: Create tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ steps.semver.outputs.version }}
git push --tags
notify:
needs: [build, should-release, release-candidate, publish, create-tag]
if: always()
name: Notify
runs-on: ubuntu-latest
steps:
- name: Discord Message on Success
if: ${{ needs.build.result != 'failure' && needs.should-release.result != 'failure' && needs.publish.result != 'failure' && needs.create-tag.result != 'failure'}}
uses: vitorvmrs/discord-send-embed@0f0cb61f7ed052734cc11765a5b2c5d0a5c3d9c2
with:
webhook-url: ${{ secrets.PI_DISCORD_WEBHOOK }}
title: "${{ github.repository }}/${{ github.ref_name }}"
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
description: "🎨 DEPLOYED / Uma linha de CSS =]"
color: 65280
footer-text: "${{ github.sha }} - ${{ github.event.head_commit.message }}"
- name: Discord Message on Failure
if: ${{ needs.build.result == 'failure' || needs.should-release.result == 'failure' || needs.publish.result == 'failure' || needs.create-tag.result == 'failure' }}
uses: vitorvmrs/discord-send-embed@0f0cb61f7ed052734cc11765a5b2c5d0a5c3d9c2
with:
webhook-url: ${{ secrets.PI_DISCORD_WEBHOOK }}
title: "${{ github.repository }}/${{ github.ref_name }}"
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
description: "❌ FAILED / Deu ruim =["
color: 16711680
footer-text: "${{ github.sha }} - ${{ github.event.head_commit.message }}"