Skip to content

Commit d418dac

Browse files
committed
chore: test action
1 parent 97965d2 commit d418dac

File tree

17 files changed

+640
-2
lines changed

17 files changed

+640
-2
lines changed

.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: Simple release
25+
run: pnpm tsm --no-warnings ./packages/ci/src/action.ts
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.simple-release.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PnpmWorkspacesProject } from './packages/pnpm/src/index.js'
2+
3+
export const project = new PnpmWorkspacesProject({
4+
mode: 'fixed'
5+
})
6+
7+
export const releaser = {
8+
verbose: true,
9+
dryRun: true
10+
}

packages/ci/.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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/ci",
9+
"project": ["./tsconfig.json"]
10+
}
11+
}

packages/ci/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "ci",
3+
"type": "module",
4+
"private": true,
5+
"version": "0.0.0",
6+
"description": "A ci utilities.",
7+
"author": {
8+
"name": "Dan Onoshko",
9+
"email": "[email protected]",
10+
"url": "https://github.com/dangreen"
11+
},
12+
"license": "MIT",
13+
"homepage": "https://github.com/TrigenSoftware/simple-release/tree/master/packages/ci#readme",
14+
"funding": "https://ko-fi.com/dangreen",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/TrigenSoftware/simple-release.git",
18+
"directory": "packages/ci"
19+
},
20+
"bugs": {
21+
"url": "https://github.com/TrigenSoftware/simple-release/issues"
22+
},
23+
"keywords": [],
24+
"engines": {
25+
"node": ">=18"
26+
},
27+
"scripts": {
28+
"lint": "eslint --parser-options tsconfigRootDir:. '**/*.{js,ts}'",
29+
"test:types": "tsc --noEmit",
30+
"test": "run -p lint test:types"
31+
},
32+
"dependencies": {
33+
"@actions/github": "^6.0.1",
34+
"@simple-release/config": "workspace:^",
35+
"@simple-release/github-action": "workspace:^"
36+
}
37+
}

packages/ci/src/action.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { getOctokit } from '@actions/github'
2+
import { load } from '@simple-release/config'
3+
import { ReleaserGithubAction } from '@simple-release/github-action'
4+
5+
const {
6+
project,
7+
releaser,
8+
...options
9+
} = await load({
10+
config: true,
11+
project: true
12+
})
13+
14+
await new ReleaserGithubAction({
15+
project,
16+
octokit: getOctokit(process.env.GITHUB_TOKEN!),
17+
...releaser
18+
})
19+
.setOptions(options)
20+
.runAction()

packages/ci/tsconfig.build.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "dist"
5+
},
6+
"include": [
7+
"src"
8+
],
9+
"exclude": [
10+
"**/*.spec.ts"
11+
]
12+
}

packages/ci/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.build.json",
3+
"include": [
4+
"src"
5+
],
6+
"exclude": []
7+
}
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/github-action",
9+
"project": ["./tsconfig.json"]
10+
},
11+
"rules": {
12+
"@typescript-eslint/naming-convention": "off"
13+
}
14+
}

packages/github-action/README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# @simple-release/github-action
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/github-action.svg
15+
[npm-url]: https://www.npmjs.com/package/@simple-release/github-action
16+
17+
[node]: https://img.shields.io/node/v/@simple-release/github-action.svg
18+
[node-url]: https://nodejs.org
19+
20+
[deps]: https://img.shields.io/librariesio/release/npm/@simple-release/github-action
21+
[deps-url]: https://libraries.io/npm/@simple-release%2Fgithub-actions/tree
22+
23+
[size]: https://packagephobia.com/badge?p=@simple-release/github-action
24+
[size-url]: https://packagephobia.com/result?p=@simple-release/github-action
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 api for github action.
33+
34+
## Install
35+
36+
```bash
37+
# pnpm
38+
pnpm add @simple-release/github-action
39+
# yarn
40+
yarn add @simple-release/github-action
41+
# npm
42+
npm i @simple-release/github-action
43+
```
44+
45+
## Usage
46+
47+
```js
48+
import { getOctokit } from '@actions/github'
49+
import { load } from '@simple-release/config'
50+
import { ReleaserGithubAction, ifReleaseCommit } from '@simple-release/github-action'
51+
52+
const {
53+
project,
54+
releaser,
55+
...options
56+
} = await load({
57+
config: true,
58+
project: true
59+
})
60+
const action = await new ReleaserGithubAction({
61+
project,
62+
octokit: getOctokit(token),
63+
...releaser
64+
})
65+
66+
// Create pull request with version bump
67+
action
68+
.setOptions(options)
69+
.checkout()
70+
.fetchOptions()
71+
.bump()
72+
.commit()
73+
.push()
74+
.pullRequest()
75+
.run()
76+
77+
// Publish release and project
78+
action
79+
.setOptions(options)
80+
.tag()
81+
.push()
82+
.release()
83+
.publish()
84+
.run(ifReleaseCommit)
85+
86+
// Run all steps to create a pull request with version bump
87+
action
88+
.setOptions(options)
89+
.runPullRequestAction()
90+
91+
// Run all steps to release project
92+
action
93+
.setOptions(options)
94+
.runReleaseAction()
95+
96+
// Detect action by commit type and run appropriate steps
97+
action
98+
.setOptions(options)
99+
.runAction()
100+
```
101+
102+
### fethchOptions
103+
104+
You can pass additional options to releaser via comment in your pull request. Your comment should start with `!simple-release/set-options` and contain JSON object with options. For example:
105+
106+
````
107+
!simple-release/set-options
108+
109+
```json
110+
{
111+
"bump": {
112+
"prerelease": "alpha"
113+
}
114+
}
115+
```
116+
````
117+
118+
To fetch and parse comments you should use `fetchOptions` step after `checkout` step.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"name": "@simple-release/github-action",
3+
"type": "module",
4+
"version": "1.0.0",
5+
"description": "A simple-release api for github action.",
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/github-action#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/github-action"
18+
},
19+
"bugs": {
20+
"url": "https://github.com/TrigenSoftware/simple-release/issues"
21+
},
22+
"keywords": [
23+
"simple-release",
24+
"github",
25+
"github-action",
26+
"release",
27+
"changelog"
28+
],
29+
"engines": {
30+
"node": ">=18"
31+
},
32+
"exports": "./src/index.ts",
33+
"publishConfig": {
34+
"exports": {
35+
"types": "./dist/index.d.ts",
36+
"import": "./dist/index.js"
37+
},
38+
"directory": "package",
39+
"linkDirectory": false
40+
},
41+
"files": [
42+
"dist"
43+
],
44+
"scripts": {
45+
"clear:package": "del ./package",
46+
"clear:dist": "del ./dist",
47+
"clear": "del ./package ./dist ./coverage",
48+
"prepublishOnly": "run build clear:package clean-publish",
49+
"postpublish": "pnpm clear:package",
50+
"build": "tsc -p tsconfig.build.json",
51+
"lint": "eslint --parser-options tsconfigRootDir:. '**/*.{js,ts}'",
52+
"test:types": "tsc --noEmit",
53+
"test": "run -p lint test:types"
54+
},
55+
"dependencies": {
56+
"@actions/github": "^6.0.1",
57+
"@simple-release/config": "workspace:^",
58+
"@simple-release/core": "workspace:^",
59+
"@simple-release/github": "workspace:^"
60+
},
61+
"devDependencies": {
62+
"@simple-release/pnpm": "workspace:^"
63+
}
64+
}

0 commit comments

Comments
 (0)