Skip to content

Main

Main #24

Workflow file for this run

name: Main
on:
workflow_dispatch:
inputs:
releaseType:
description: "Release Type"
required: true
default: "prerelease"
type: choice
options:
- major
- minor
- patch
- prerelease
push:
branches:
- "main"
tags-ignore:
- "*"
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
RELEASE_TYPE: ${{ github.event_name == 'push' && 'prerelease' || github.event.inputs.releaseType }}
# This can only be triggered from main
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTIONS_DEPLOY_KEY_RULE_BYPASS }}
- uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".tool-versions"
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- run: pnpm install nx --global
- run: pnpm run lint:ci
- run: pnpm run format:ci
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "Zudoku Bot"
- name: Version Bump (Zudoku)
run: pnpm version ${{ env.RELEASE_TYPE }} --preid dev
working-directory: packages/zudoku
- name: Version Bump (Create App)
run: pnpm version ${{ env.RELEASE_TYPE }} --preid dev
working-directory: packages/create-zudoku-app
# Build must happen after version bump so builds use the correct version
- run: nx run-many -t build:ci
- run: git add -A
- run: echo "ZUDOKU_VERSION=$(node -e 'console.log(require(`./packages/zudoku/package.json`).version)')" >> $GITHUB_ENV
# Push changes before publishing because if it fails we still want the tag
- name: Commit & Push Changes
run: |
git commit -m "[Version] ${{ env.ZUDOKU_VERSION }} [skip ci]" --no-verify
git tag ${{ env.ZUDOKU_VERSION }}
git push origin main --tags
- name: Publish Module (Zudoku)
run: pnpm publish --provenance --filter zudoku --tag ${{ env.RELEASE_TYPE == 'prerelease' && 'dev' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Publish Module (Create App)
run: pnpm publish --provenance --filter create-zudoku-app --tag ${{ env.RELEASE_TYPE == 'prerelease' && 'dev' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
token_format: "access_token"
workload_identity_provider: ${{ vars.GCP_ACTIONS_IDENTITY_PROVIDER }}
service_account: github-actions-opensource@zuplo-production.iam.gserviceaccount.com
access_token_lifetime: "300s"
- name: Upload CSS
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.css"
destination: cdn.zudoku.dev/${{ env.ZUDOKU_VERSION }}
parent: false
headers: |-
content-type: text/css
- name: Upload Javascript
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.js"
destination: cdn.zudoku.dev/${{ env.ZUDOKU_VERSION }}
parent: false
headers: |-
content-type: text/javascript
- name: Upload HTML (Latest)
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone/index.html
destination: cdn.zudoku.dev/latest
parent: false
headers: |-
content-type: text/html
- name: Upload CSS (Latest)
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.css"
destination: cdn.zudoku.dev/latest
parent: false
headers: |-
content-type: text/css
- name: Upload Javascript (Latest)
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.js"
destination: cdn.zudoku.dev/latest
parent: false
headers: |-
content-type: text/javascript
- name: Upload Artifacts
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/stats.html
destination: cdn.zudoku.dev/build/rollup/${{ github.run_id }}-${{ github.run_attempt }}
parent: false
headers: |-
content-type: text/html
- name: Clear CDN Cache
run: |
curl --request POST \
--url https://api.cloudflare.com/client/v4/zones/1abaefabd6800e9979a740a7cdf235a8/purge_cache \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${{ secrets.CF_ZONE_PURGE_ACCESS_TOKEN }}' \
--data '{
"files": [
"https://cdn.zudoku.dev/demo",
"https://cdn.zudoku.dev/demo/",
"https://cdn.zudoku.dev/demo/index.html",
"https://cdn.zudoku.dev/latest",
"https://cdn.zudoku.dev/latest/",
"https://cdn.zudoku.dev/latest/index.html",
"https://cdn.zudoku.dev/latest/main.js",
"https://cdn.zudoku.dev/latest/demo.js",
"https://cdn.zudoku.dev/latest/style.css"
]
}'
- name: Write Summary
run: |
echo "📝 Bundle stats uploaded" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[View Stats](https://cdn.zudoku.dev/build/rollup/${{ github.run_id }}-${{ github.run_attempt }}/stats.html)" >> $GITHUB_STEP_SUMMARY
- uses: ncipollo/release-action@v1
if: env.RELEASE_TYPE != 'prerelease'
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Trigger updates of internal projects using Zudoku
- run: gh workflow run release.yaml --repo zuplo-poc/docs-zudoku --ref main
env:
GITHUB_TOKEN: ${{ secrets.GH_SECRET_TRIGGER_POC_WORKFLOWS }}