Skip to content

Commit 0d4cd2d

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

File tree

18 files changed

+657
-2
lines changed

18 files changed

+657
-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: Create pull request with release changes
25+
run: pnpm tsm --no-warnings ./packages/ci/src/pr.ts
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.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/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/pr.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { getOctokit } from '@actions/github'
2+
import { load } from '@simple-release/config'
3+
import { ReleaserGithubAction, ifReleaseCommit } 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+
// await new ReleaserGithubAction({
14+
// project,
15+
// octokit: getOctokit(process.env.GITHUB_TOKEN!),
16+
// ...releaser
17+
// })
18+
// .setOptions(options)
19+
// .runPullRequestAction()
20+
const r = new ReleaserGithubAction({
21+
project,
22+
octokit: getOctokit(process.env.GITHUB_TOKEN!),
23+
...releaser
24+
})
25+
.setOptions(options)
26+
27+
console.log({
28+
ifReleaseCommit: await ifReleaseCommit(r)
29+
})
30+
31+
await r.runPullRequestAction()

packages/ci/src/release.ts

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

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: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
61+
// Create pull request with version bump
62+
await new Releaser({
63+
project,
64+
octokit: getOctokit(token),
65+
...releaser
66+
})
67+
.setOptions(options)
68+
.checkout()
69+
.fetchOptions()
70+
.bump()
71+
.commit()
72+
.push()
73+
.pullRequest()
74+
.run()
75+
76+
// Publish release and project
77+
await new Releaser({
78+
project,
79+
octokit: getOctokit(token),
80+
...releaser
81+
})
82+
.setOptions(options)
83+
.tag()
84+
.push()
85+
.release()
86+
.publish()
87+
.run(ifReleaseCommit)
88+
```
89+
90+
### fethchOptions
91+
92+
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:
93+
94+
````
95+
!simple-release/set-options
96+
97+
```json
98+
{
99+
"bump": {
100+
"prerelease": "alpha"
101+
}
102+
}
103+
```
104+
````
105+
106+
To fetch and parse comments you should use `fetchOptions` step after `checkout` step.

0 commit comments

Comments
 (0)