mirror of
https://github.com/spartan-ng/spartan.git
synced 2026-09-22 16:41:38 +08:00
e1d349e431
The release job ran in parallel with cli-smoke. Because release publishes new @spartan-ng versions to npm mid-run, the smoke healthcheck saw the package "latest" change underneath it and the angular-cli cells failed. Add commitlint and cli-smoke to the release job's `needs` so a red suite blocks the publish, and so release waits for cli-smoke to finish before publishing - which removes the concurrent-publish race.
186 lines
5.7 KiB
YAML
186 lines
5.7 KiB
YAML
name: nightly-release
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 0 * * *'
|
|
|
|
jobs:
|
|
check_date:
|
|
runs-on: ubuntu-latest
|
|
name: Check latest commit
|
|
outputs:
|
|
should_run: ${{ steps.should_run.outputs.should_run }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- name: print latest_commit
|
|
run: echo ${{ github.sha }}
|
|
|
|
- id: should_run
|
|
continue-on-error: true
|
|
name: check latest commit is less than a day
|
|
if: ${{ github.event_name == 'schedule' }}
|
|
# This command checks if there were any commits in the last 24 hours.
|
|
# If there were NO recent commits, it sets should_run=false.
|
|
# How it works:
|
|
# 1. git rev-list gets a list of all commits in last 24h
|
|
# (--after="24 hours" means "show commits from 24h ago until now",
|
|
# so if it runs at 2pm, it checks commits after 2pm yesterday)
|
|
# 2. test -z checks if that list is empty (meaning no recent commits)
|
|
# 3. If empty (no commits), it sets GitHub Actions output variable 'should_run' to false
|
|
# This output variable can then be used in other workflow steps like:
|
|
# if: ${{ steps.your-step-id.outputs.should_run != 'false' }}
|
|
# to skip steps when there were no recent commits
|
|
run: |
|
|
if test -z "$(git rev-list --after='23 hours 55 minutes' '${{ github.sha }}')"; then
|
|
echo "should_run=false" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "should_run=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
commitlint:
|
|
needs: check_date
|
|
if: ${{ needs.check_date.outputs.should_run != 'false' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: read
|
|
contents: read
|
|
# Required by wagoid/commitlint-github-action
|
|
pull-requests: read
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
# Required by wagoid/commitlint-github-action
|
|
fetch-depth: 0
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v5
|
|
- name: Install Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: 'pnpm'
|
|
- name: Lint commit messages
|
|
uses: wagoid/commitlint-github-action@v5
|
|
with:
|
|
failOnWarnings: true
|
|
helpURL: https://github.com/goetzrobin/spartan/blob/main/CONTRIBUTING.md#-commit-message-guidelines
|
|
|
|
format-and-lint:
|
|
needs: check_date
|
|
if: ${{ needs.check_date.outputs.should_run != 'false' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
# Required by wagoid/commitlint-github-action
|
|
fetch-depth: 0
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v5
|
|
- name: Install Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: 'pnpm'
|
|
- name: Install Dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: lint
|
|
run: pnpm run lint
|
|
- name: format
|
|
run: pnpm nx format:check --base=origin/main
|
|
|
|
build:
|
|
needs: check_date
|
|
if: ${{ needs.check_date.outputs.should_run != 'false' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
# Required by wagoid/commitlint-github-action
|
|
fetch-depth: 0
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v5
|
|
- name: Install Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: 'pnpm'
|
|
- name: Install Dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Build
|
|
run: pnpm run build
|
|
|
|
cli-smoke:
|
|
needs: check_date
|
|
if: ${{ needs.check_date.outputs.should_run != 'false' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v5
|
|
- name: Install Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: 'pnpm'
|
|
- name: Install Dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
# Run the full CLI smoke matrix unconditionally (not just affected) every night.
|
|
- name: CLI smoke matrix (full)
|
|
run: pnpm nx run-many -t smoke --parallel=1 --outputStyle=stream
|
|
|
|
release:
|
|
needs:
|
|
- check_date
|
|
- commitlint
|
|
- build
|
|
- format-and-lint
|
|
- cli-smoke
|
|
if: ${{ needs.check_date.outputs.should_run != 'false' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
# Required by wagoid/commitlint-github-action
|
|
fetch-depth: 0
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v5
|
|
- name: Install Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .node-version
|
|
cache: 'pnpm'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
- name: Upgrade npm for trusted publishing
|
|
run: npm i -g npm@^11.5.1
|
|
- name: Print npm version
|
|
run: npm -v
|
|
- name: Install Dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Pre Release
|
|
run: pnpm run pre-nightly-release
|
|
- name: Get the current date time
|
|
id: datetime
|
|
run: echo "release_date=$(date '+%Y-%m-%d')" >> $GITHUB_OUTPUT
|
|
- name: Commit changes
|
|
uses: EndBug/add-and-commit@v9
|
|
with:
|
|
author_name: Leonidas
|
|
author_email: leonidas@spartan.ng
|
|
message: 'chore: nightly release ${{steps.datetime.outputs.release_date}} ⚡'
|
|
- name: Release
|
|
run: |
|
|
unset NODE_AUTH_TOKEN
|
|
unset NPM_TOKEN
|
|
pnpm run release
|
|
env:
|
|
TAG: ${{ secrets.TAG }}
|