Skip to content

Deploy Pipelines - Release and Publish #197

Deploy Pipelines - Release and Publish

Deploy Pipelines - Release and Publish #197

name: Deploy Pipelines - Release and Publish
on:
workflow_dispatch:
inputs:
ref:
required: true
description: Branch from which do the release
type: string
type:
required: false
description: It is a release or an hotfix
type: choice
options:
- release
- hotfix
final_release:
description: It is a final release
type: boolean
required: false
main_branch:
description: The name of the main branch towards which to open the merge pr with the release branch
type: string
default: main
required: true
concurrency:
group: ${{ github.workflow }}-cd
cancel-in-progress: true
permissions:
id-token: write # Required trusted publishing
pull-requests: write
contents: write
jobs:
release:
runs-on: ubuntu-24.04
environment: prod-cd
outputs:
release_branch: ${{ steps.release.outputs.release_branch }}
release_id: ${{ steps.release.outputs.release_id }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{inputs.ref}}
fetch-depth: 0
sparse-checkout: |
.github
package.json
CHANGELOG.md
- name: Setup Git Config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Install Packages
run: npm ci
working-directory: .github/workflows/actions/release
- name: Release
id: release
uses: ./.github/workflows/actions/release
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{inputs.ref}}
type: ${{inputs.type}}
final_release: ${{inputs.final_release}}
main_branch: ${{inputs.main_branch}}
build:
needs: release
runs-on: ubuntu-24.04
steps:
- name: Check-out code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
ref: ${{ needs.release.outputs.release_branch }}
# the action setup-node fails if it tries to install yarn while running locally with nekos/act
# so we need to skip the yarn installation and do it manually in the next step
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: '24'
cache: ${{ !github.event.act && 'yarn' || '' }}
cache-dependency-path: ${{ !github.event.act && 'yarn.lock' || '' }}
# this is to try the action locally with nekos/act
- name: Install Yarn globally
if: ${{ github.event.act }}
run: npm install -g yarn
- name: Install dependencies
run: yarn install --immutable
working-directory: .
- name: Build
run: yarn build
working-directory: .
# the upload of the artifcat cannot be done locally with nekos/act
- name: Upload Artifact
if: ${{ !github.event.act }}
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: 'bundle'
path: 'dist'
if-no-files-found: error
retention-days: 7
deploy:
if: ${{ !github.event.act }}
needs: [release, build]
runs-on: ubuntu-24.04
environment: prod-cd
env:
NPM_REGISTRY: 'registry.npmjs.org'
steps:
- name: Download Artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: 'bundle'
path: 'bundle'
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Publish
run: |
npm publish --access public --verbose --tag ${{ inputs.final_release && 'latest' || 'rc' }}
working-directory: 'bundle'