Skip to content

Commit 100e376

Browse files
committed
chore: test action
1 parent cdb8f23 commit 100e376

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1890
-556
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: simple-release
2+
description: A simple tool to release projects with monorepo support.
3+
inputs:
4+
action:
5+
description: |
6+
Action that simple-release should do:
7+
- pr - create pull request with release changes
8+
- release - create tags, release notes and publish, only if pull request with fresh release was merged
9+
default: pr
10+
token:
11+
description: GitHub Token
12+
branch:
13+
description: Branch name to store release changes
14+
default: simple-release
15+
runs:
16+
using: node20
17+
main: dist/index.js

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- action
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
name: Release
10+
steps:
11+
- name: Checkout the repository
12+
uses: actions/checkout@v4
13+
- name: Install pnpm
14+
uses: pnpm/action-setup@v2
15+
with:
16+
version: 10
17+
- name: Install Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18
21+
cache: 'pnpm'
22+
- name: Install dependencies
23+
run: pnpm install
24+
- name: Create pull request with release changes
25+
run: pnpm tsm --no-warnings ./packages/github-action/src/_pr.ts
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ node_modules
2323
dist
2424
packages/*/package
2525
build
26+
!.github/actions/*/dist
27+
!.github/actions/*/dist/node_modules
2628

2729
# Env files
2830
.env

.simple-release.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { PnpmWorkspacesProject } from './packages/pnpm/src/index.js'
2+
// import { GithubHosting } from './packages/github/src/index.js'
3+
4+
export const project = new PnpmWorkspacesProject({
5+
mode: 'fixed'
6+
})
7+
8+
// export const hosting = new GithubHosting({
9+
// token: process.env.GITHUB_TOKEN
10+
// })
11+
12+
export const releaser = {
13+
verbose: true
14+
}
15+
16+
// export const bump = {
17+
// byProject: {
18+
// 'simple-github-release': {
19+
// firstRelease: false
20+
// }
21+
// }
22+
// }

packages/config/.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": [
3+
"@trigen/eslint-config/typescript",
4+
"@trigen/eslint-config/typescript-requiring-type-checking",
5+
"@trigen/eslint-config/jest"
6+
],
7+
"parserOptions": {
8+
"tsconfigRootDir": "./packages/config",
9+
"project": ["./tsconfig.json"]
10+
},
11+
"rules": {
12+
"@typescript-eslint/naming-convention": "off"
13+
}
14+
}

packages/config/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# @simple-release/config
2+
3+
[![ESM-only package][package]][package-url]
4+
[![NPM version][npm]][npm-url]
5+
[![Node version][node]][node-url]
6+
[![Dependencies status][deps]][deps-url]
7+
[![Install size][size]][size-url]
8+
[![Build status][build]][build-url]
9+
[![Coverage status][coverage]][coverage-url]
10+
11+
[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
12+
[package-url]: https://nodejs.org/api/esm.html
13+
14+
[npm]: https://img.shields.io/npm/v/@simple-release/config.svg
15+
[npm-url]: https://www.npmjs.com/package/@simple-release/config
16+
17+
[node]: https://img.shields.io/node/v/@simple-release/config.svg
18+
[node-url]: https://nodejs.org
19+
20+
[deps]: https://img.shields.io/librariesio/release/npm/@simple-release/config
21+
[deps-url]: https://libraries.io/npm/@simple-release%2Fconfig/tree
22+
23+
[size]: https://packagephobia.com/badge?p=@simple-release/config
24+
[size-url]: https://packagephobia.com/result?p=@simple-release/config
25+
26+
[build]: https://img.shields.io/github/actions/workflow/status/TrigenSoftware/simple-release/tests.yml?branch=main
27+
[build-url]: https://github.com/TrigenSoftware/simple-release/actions
28+
29+
[coverage]: https://coveralls.io/repos/github/TrigenSoftware/simple-release/badge.svg?branch=main
30+
[coverage-url]: https://coveralls.io/github/TrigenSoftware/simple-release?branch=main
31+
32+
A simple-release config loader.
33+
34+
## Install
35+
36+
```bash
37+
# pnpm
38+
pnpm add @simple-release/config
39+
# yarn
40+
yarn add @simple-release/config
41+
# npm
42+
npm i @simple-release/config
43+
```
44+
45+
## Usage
46+
47+
```js
48+
import { load } from '@simple-release/config'
49+
50+
await load() // Returns `SimpleReleaseConfig | null`
51+
await load({ config: true }) // Returns `SimpleReleaseConfig` or throws an error if config is not found
52+
await load({ [propertyName]: true }) // Returns `SimpleReleaseConfig & { [propertyName]: NotEmpty } | null` or throws an error if property is not set
53+
```

packages/config/package.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@simple-release/config",
3+
"type": "module",
4+
"version": "1.0.0",
5+
"description": "A simple-release config loader.",
6+
"author": {
7+
"name": "Dan Onoshko",
8+
"email": "[email protected]",
9+
"url": "https://github.com/dangreen"
10+
},
11+
"license": "MIT",
12+
"homepage": "https://github.com/TrigenSoftware/simple-release/tree/master/packages/config#readme",
13+
"funding": "https://ko-fi.com/dangreen",
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/TrigenSoftware/simple-release.git",
17+
"directory": "packages/config"
18+
},
19+
"bugs": {
20+
"url": "https://github.com/TrigenSoftware/simple-release/issues"
21+
},
22+
"keywords": [
23+
"simple-release",
24+
"config",
25+
"loader"
26+
],
27+
"engines": {
28+
"node": ">=18"
29+
},
30+
"exports": "./src/index.ts",
31+
"publishConfig": {
32+
"exports": {
33+
"types": "./dist/index.d.ts",
34+
"import": "./dist/index.js"
35+
},
36+
"directory": "package",
37+
"linkDirectory": false
38+
},
39+
"files": [
40+
"dist"
41+
],
42+
"scripts": {
43+
"clear:package": "del ./package",
44+
"clear:dist": "del ./dist",
45+
"clear": "del ./package ./dist ./coverage",
46+
"prepublishOnly": "run build clear:package clean-publish",
47+
"postpublish": "pnpm clear:package",
48+
"build": "tsc -p tsconfig.build.json",
49+
"lint": "eslint --parser-options tsconfigRootDir:. '**/*.{js,ts}'",
50+
"test:types": "tsc --noEmit",
51+
"test": "run -p lint test:types"
52+
},
53+
"dependencies": {
54+
"@simple-release/core": "workspace:^",
55+
"find-up-simple": "^1.0.1"
56+
}
57+
}

packages/config/src/index.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { findUp } from 'find-up-simple'
3+
import type {
4+
ReleaserStepsOptions,
5+
Project,
6+
GitRepositoryHosting,
7+
ReleaserOptions
8+
} from '@simple-release/core'
9+
10+
const VARIANTS = [
11+
'.simple-release.js',
12+
'.simple-release.mjs',
13+
'.simple-release.cjs'
14+
]
15+
16+
export interface SimpleReleaseConfig<
17+
P extends Project = Project,
18+
G extends GitRepositoryHosting = GitRepositoryHosting
19+
> extends ReleaserStepsOptions<P, G> {
20+
project?: P
21+
hosting?: G
22+
releaser?: Omit<ReleaserOptions, 'project' | 'hosting'>
23+
}
24+
25+
export type SimpleReleaseConfigRequirements = {
26+
config?: boolean
27+
} & {
28+
[K in keyof SimpleReleaseConfig]?: boolean
29+
}
30+
31+
type ApplyRequirements<T extends Record<string, any>, R extends Record<string, any>> = {
32+
[K in keyof T as K extends keyof R ? R[K] extends true ? K : never : never]-?: Exclude<T[K], undefined>
33+
} & {
34+
[K in keyof T as K extends keyof R ? R[K] extends true ? never : K : K]: T[K]
35+
}
36+
37+
type ApplyConfigRequirement<R extends { config?: boolean }, T> = R extends { config: true }
38+
? T
39+
: T | null
40+
41+
type Result<
42+
P extends Project = Project,
43+
G extends GitRepositoryHosting = GitRepositoryHosting,
44+
R extends SimpleReleaseConfigRequirements = SimpleReleaseConfigRequirements
45+
> = ApplyRequirements<SimpleReleaseConfig<P, G>, R> extends infer C
46+
? ApplyConfigRequirement<R, C>
47+
: never
48+
49+
function validate(target: Record<string, any>, rules: Record<string, any>) {
50+
for (const [rule, required] of Object.entries(rules)) {
51+
if (required && target[rule] === undefined) {
52+
throw new Error(`Faild to load config: '${rule}' is required`)
53+
}
54+
}
55+
}
56+
57+
/**
58+
* Load simple-release config.
59+
* @param requirements
60+
* @returns simple-release config
61+
*/
62+
export async function load<
63+
P extends Project = Project,
64+
G extends GitRepositoryHosting = GitRepositoryHosting,
65+
R extends SimpleReleaseConfigRequirements = SimpleReleaseConfigRequirements
66+
>(requirements?: R): Promise<Result<P, G, R>>
67+
68+
export async function load(requirements: Record<string, any> = {}) {
69+
const {
70+
config: configRequired,
71+
...reqs
72+
} = requirements
73+
74+
for (const variant of VARIANTS) {
75+
const foundPath = await findUp(variant)
76+
77+
if (foundPath) {
78+
try {
79+
const module = await import(foundPath) as SimpleReleaseConfig | { default: SimpleReleaseConfig }
80+
const config = 'default' in module ? module.default : module
81+
82+
validate(config, reqs)
83+
84+
return config
85+
} catch (err) {
86+
if (configRequired) {
87+
throw err
88+
}
89+
90+
return null
91+
}
92+
}
93+
}
94+
95+
if (configRequired) {
96+
throw new Error('Config not found')
97+
}
98+
99+
return null
100+
}
File renamed without changes.

0 commit comments

Comments
 (0)