CD #138
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
--- | |
name: 'CD' | |
on: | |
workflow_run: | |
workflows: ['CI'] | |
types: | |
- completed | |
jobs: | |
tag: | |
runs-on: ubuntu-24.04 | |
name: Tag the release | |
if: startsWith(github.event.workflow_run.head_commit.message, 'bump:') | |
permissions: | |
contents: write | |
outputs: | |
version: ${{ steps.calculate_version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: true | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- name: Set git user info | |
run: | | |
git config user.name 'Temeraire' | |
git config user.email '[email protected]' | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Calculate the next version | |
id: calculate_version | |
run: | | |
PATH=$(pnpm bin):$PATH | |
VERSION=$(git cliff --bumped-version) | |
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
- name: Install jq | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install jq | |
- name: Update package.json | |
run: | | |
JQ_VERSION=${{ steps.calculate_version.outputs.version }} jq '.version=env.JQ_VERSION' ./core/package.json > /tmp/package.json | |
mv /tmp/package.json ./core/package.json | |
git add ./core/package.json | |
git commit -m "chore(core): bump version to ${{ steps.calculate_version.outputs.version }}" | |
- name: Tag the release | |
run: | | |
git tag ${{ steps.calculate_version.outputs.version }} -m "${{ steps.calculate_version.outputs.version }}" | |
- name: Push changes | |
uses: ad-m/[email protected] | |
with: | |
branch: ${{ github.ref }} | |
ssh: true | |
tags: true | |
changelog: | |
runs-on: ubuntu-24.04 | |
needs: [tag] | |
name: Generate and commit changelog | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: true | |
ref: ${{ needs.tag.outputs.version }} | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
- name: Set git user info | |
run: | | |
git config user.name 'Temeraire' | |
git config user.email '[email protected]' | |
- name: Generate a complete changelog | |
uses: orhun/git-cliff-action@v4 | |
with: | |
config: cliff.toml | |
args: -v --no-exec --github-repo ${{ github.repository }} | |
env: | |
OUTPUT: CHANGELOG.md | |
- name: Commit changelog | |
run: | | |
git checkout main | |
git add CHANGELOG.md | |
git commit -m "docs(changelog.md): update [skip ci]" | |
- name: Push changes | |
uses: ad-m/[email protected] | |
with: | |
ssh: true | |
branch: ${{ github.ref }} | |
- name: Generate a changelog for the latest release | |
uses: orhun/git-cliff-action@v4 | |
with: | |
config: cliff.toml | |
args: -v --no-exec --github-repo ${{ github.repository }} --latest --strip header | |
env: | |
GITHUB_REPO: ${{ github.repository }} | |
OUTPUT: CHANGES.md | |
- name: Get current tag | |
id: get_tag | |
run: echo "tag_name=$(git describe --abbrev=0 --tags)" >> "$GITHUB_OUTPUT" | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: CHANGES.md | |
fail_on_unmatched_files: true | |
tag_name: ${{ steps.get_tag.outputs.tag_name }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
runs-on: ubuntu-24.04 | |
needs: [tag] | |
name: Publish to NPM | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.tag.outputs.version }} | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
registry-url: https://registry.npmjs.org/ | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
# https://github.com/pnpm/pnpm/issues/4937 | |
- name: Set up special NPM voodoo | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
echo "@garudalinux:registry=https://registry.npmjs.org/" >> ~/.npmrc | |
- name: Publish to NPM | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: pnpx nx run core:publish | |
publish-docs: | |
runs-on: ubuntu-24.04 | |
needs: [tag] | |
name: Deploy docs to Cloudflare Pages | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout tag | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.tag.outputs.version }} | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build the documentation | |
run: pnpx nx build docs | |
- name: Deploy Cloudflare Pages | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
command: pages deploy --branch main | |
packageManager: pnpm |