Skip to content

Commit

Permalink
build: setup nightly release (#524)
Browse files Browse the repository at this point in the history
* chore: lint and cleanup of touched files

* build: add executor to replace version for ui libs

this executor finds all package.json in the libs/ui directory
and replaces the current version
of @spartan-ng with the one defined in UI_VERSION

* build: update cli files to reflect new versions and add scripts to make publishing easier

* chore: fix linting errors

* build: update semantic release config

* build: use same VERSION env var for ui and cli

* fix: remove confusing comment

* fix: add regex only updating spartan specific versions

and a unit test to make sure we don't accidentally mess with other packages

* fix: remove .DS_Store files and filter helm packages to not add them to package.json

* chore: remove unused script

* chore: add generator that auto-increments current version of released assets

* chore: add scripts for nightly release

* chore: add nightly release workflow

* fix: add missing dash

* chore: try on push for testing

* build: auto fix version number in tools

* ci: set up automatic release and committing of changed files

* ci: give release step write permissions

* ci: check out branch correctly so we can commit it back

* ci: try to push to right place

* chore: reorder package.json

* fix: use newVersion to allow for auto increment script to work

* chore: update branch name

* fix: rename release scripts and interface and add missing generators

* chore: release cli & ui 0.0.1-alpha.379

* chore: fix name for trigger

* chore: try to push to origin nightly-release

* chore: nightly release 2024-12-10 ⚡

* chore: update tools version number

* chore: nightly release 2024-12-10 ⚡

* chore: update github flow to work on main and a schedule

* fix: add back lost test and start commands to package.json

* fix: fix tests and commit message to follow guidelines

* feat: adjust version replacement for new single brain package

* fix: use correct alpha version 381

* fix: add back storybook command to package.json

* fix: typo in @spartan-ng/brain version for pagination helm

* fix: remove tests that don't do anything and add formatting of files

---------

Co-authored-by: Leonidas <[email protected]>
  • Loading branch information
goetzrobin and Leonidas authored Jan 8, 2025
1 parent 74d4016 commit cd6e903
Show file tree
Hide file tree
Showing 68 changed files with 524 additions and 344 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
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@v2
- 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' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"

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@v4
with:
# Required by wagoid/commitlint-github-action
fetch-depth: 0
- name: Install Node v22
uses: actions/setup-node@v4
with:
node-version-file: .node-version
- name: Install pnpm globally
run: npm install -g 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@v4
with:
# Required by wagoid/commitlint-github-action
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
- name: Install PNPM globally
run: npm install -g 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@v4
with:
# Required by wagoid/commitlint-github-action
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
- name: Install PNPM globally
run: npm install -g pnpm
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build

release:
needs:
- check_date
- build
- format-and-lint
if: ${{ needs.check_date.outputs.should_run != 'false' }}

runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
# Required by wagoid/commitlint-github-action
fetch-depth: 0
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
- name: Install PNPM globally
run: npm install -g pnpm
- 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: [email protected]
message: 'chore: nightly release ${{steps.datetime.outputs.release_date}} ⚡'
- name: Release
run: pnpm run release
24 changes: 0 additions & 24 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion libs/brain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spartan-ng/brain",
"version": "0.0.1-alpha.357",
"version": "0.0.1-alpha.381",
"sideEffects": false,
"exports": {
"./hlm-tailwind-preset": {
Expand Down
2 changes: 1 addition & 1 deletion libs/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spartan-ng/cli",
"version": "0.0.1-alpha.367",
"version": "0.0.1-alpha.381",
"type": "commonjs",
"dependencies": {
"@nx/angular": ">=20.0.0",
Expand Down
2 changes: 1 addition & 1 deletion libs/cli/src/generators/base/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const FALLBACK_ANGULAR_VERSION = '^18.0.0';
// ng-icon dependency
export const NG_ICONS_VERSION = '^29.10.0';
// spartan dependencies
export const SPARTAN_BRAIN_VERSION = '0.0.1-alpha.357';
export const SPARTAN_BRAIN_VERSION = '0.0.1-alpha.381';
// dev dependencies
export const TAILWIND_MERGE_VERSION = '^2.2.0';
export const TAILWINDCSS_VERSION = '^3.0.2';
Expand Down
13 changes: 9 additions & 4 deletions libs/cli/src/generators/ui/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export default async function hlmUIGenerator(tree: Tree, options: HlmUIGenerator
const config = await getOrCreateConfig(tree, {
componentsPath: options.directory,
});
const availablePrimitives: ComponentDefintions = await import('./supported-ui-libraries.json').then((m) => m.default);
const availablePrimitives: PrimitiveDefinitions = await import('./supported-ui-libraries.json').then(
(m) => m.default,
);
const availablePrimitiveNames = [...Object.keys(availablePrimitives), 'collapsible', 'menubar', 'contextmenu'];
let response: { primitives: string[] } = { primitives: [] };
if (options.name && availablePrimitiveNames.includes(options.name)) {
Expand All @@ -35,7 +37,7 @@ async function createPrimitiveLibraries(
primitives: string[];
},
availablePrimitiveNames: string[],
availablePrimitives: ComponentDefintions,
availablePrimitives: PrimitiveDefinitions,
tree: Tree,
options: HlmUIGeneratorSchema & { angularCli?: boolean },
config: Config,
Expand All @@ -59,7 +61,7 @@ async function createPrimitiveLibraries(
if (primitiveName === 'collapsible') return;

const internalName = availablePrimitives[primitiveName].internalName;
const peerDependencies = availablePrimitives[primitiveName].peerDependencies;
const peerDependencies = removeHelmKeys(availablePrimitives[primitiveName].peerDependencies);
const { generator } = await import(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down Expand Up @@ -108,7 +110,10 @@ const replaceContextAndMenuBar = async (primtivesToCreate: string[], silent = fa
}
};

interface ComponentDefintions {
const removeHelmKeys = (obj: Record<string, string>) =>
Object.fromEntries(Object.entries(obj).filter(([key]) => !key.toLowerCase().includes('helm')));

interface PrimitiveDefinitions {
[componentName: string]: {
internalName: string;
peerDependencies: Record<string, string>;
Expand Down
Loading

0 comments on commit cd6e903

Please sign in to comment.