mirror of
https://github.com/yanhao98/semantic-release-action.git
synced 2025-07-12 23:30:48 +08:00
feat: first commit
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
* text=auto
|
||||
/dist/index.js binary
|
22
.github/workflows/ci.yaml
vendored
Normal file
22
.github/workflows/ci.yaml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: 持续集成
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
concurrency:
|
||||
group: 'ci'
|
||||
cancel-in-progress: true
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: # Job-level permissions configuration starts here
|
||||
contents: write # 'write' access to repository contents
|
||||
pull-requests: write # 'write' access to pull requests
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- uses: yanhao98/semantic-release-example@main
|
27
.github/workflows/semantic-release-action.yaml.off
vendored
Normal file
27
.github/workflows/semantic-release-action.yaml.off
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
name: cycjimmy/semantic-release-action
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Semantic Release
|
||||
uses: cycjimmy/semantic-release-action@v4
|
||||
with:
|
||||
dry_run: true
|
||||
id: semantic # Need an `id` for output variables
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Do something when a new release published
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
echo ${{ steps.semantic.outputs.new_release_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_major_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_minor_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_patch_version }}
|
35
.github/workflows/semantic-release.yaml.off
vendored
Normal file
35
.github/workflows/semantic-release.yaml.off
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: 持续集成
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
concurrency:
|
||||
group: 'ci'
|
||||
cancel-in-progress: true
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: # Job-level permissions configuration starts here
|
||||
contents: write # 'write' access to repository contents
|
||||
pull-requests: write # 'write' access to pull requests
|
||||
steps:
|
||||
- uses: yanhao98/composite-actions/setup-node-environment@main
|
||||
# - run: npx semantic-release@24
|
||||
# if: ${{ vars.GITEA_ACTIONS != 'true' }}
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# --dry-run
|
||||
|
||||
- run: node run.mjs
|
||||
id: semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Get the output
|
||||
run: echo "The output was ${{ steps.semantic-release.outputs.version }}"
|
||||
# - run: git status
|
||||
# - name: 检查是否有未推送的 tag
|
||||
# run: git tag -l --sort=-creatordate | while read tag; do git ls-remote --tags origin | grep -q "$tag" || echo "$tag"; done
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
/dist/*
|
||||
!/dist/index.js
|
28
README.md
Normal file
28
README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# semantic-release-example
|
||||
|
||||
https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type
|
||||
|
||||
- **feat**: 一项新功能
|
||||
- **fix**: 错误修复
|
||||
- **docs**: 仅更改文档
|
||||
- **style**: 不影响代码含义的更改(空格、格式、缺少分号等)
|
||||
- **refactor**: 既不修复错误也不添加功能的代码更改
|
||||
- **perf**: 提高性能的代码更改
|
||||
- **test**: 添加缺失的或纠正现有的测试
|
||||
- **chore**: 对构建过程或辅助工具和库(例如文档生成)的更改
|
||||
```
|
||||
BREAKING CHANGE:
|
||||
```
|
||||
|
||||
## 参考
|
||||
---
|
||||
- [Can I run semantic-release on my local machine rather than on a CI server?](https://semantic-release.gitbook.io/semantic-release/support/faq#can-i-run-semantic-release-on-my-local-machine-rather-than-on-a-ci-server)
|
||||
- [Can I use semantic-release to publish non-JavaScript packages?](https://semantic-release.gitbook.io/semantic-release/support/faq#can-i-use-semantic-release-to-publish-non-javascript-packages)
|
||||
- [pre-release-branches](https://semantic-release.gitbook.io/semantic-release/usage/workflow-configuration#pre-release-branches)
|
||||
|
||||
---
|
||||
- [renovate's build.yml](https://github.com/renovatebot/renovate/blob/9ed6666aeb15f4cd795c598e4007c097aa4c4cc8/.github/workflows/build.yml#L715)
|
||||
|
||||
---
|
||||
- [release-please](https://github.com/googleapis/release-please/blob/main/docs/cli.md)
|
||||
- [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version)
|
10
action.yml
Normal file
10
action.yml
Normal file
@ -0,0 +1,10 @@
|
||||
name: 'The name of your action here'
|
||||
description: 'Provide a description here'
|
||||
author: 'Your name or organization here'
|
||||
branding:
|
||||
icon: 'heart'
|
||||
color: 'red'
|
||||
runs:
|
||||
# pre: 'index.mjs'
|
||||
using: 'node20'
|
||||
main: 'index.mjs'
|
33
index.mjs
Normal file
33
index.mjs
Normal file
@ -0,0 +1,33 @@
|
||||
import { exec as execCallback } from 'node:child_process';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { promisify } from 'node:util';
|
||||
const exec = promisify(execCallback);
|
||||
const self_cwd = dirname(fileURLToPath(import.meta.url));
|
||||
import packageJson from './package.json' with { type: "json" };
|
||||
|
||||
// https://github.dev/cycjimmy/semantic-release-action
|
||||
async function installDependencies() {
|
||||
// const _extras = extras.replace(/['"]/g, '').replace(/[\n\r]/g, ' ');
|
||||
const deps = ['semantic-release'].join(' ');
|
||||
const { stdout, stderr } = await exec(`npm install ${deps} --no-audit --no-save`, {
|
||||
cwd: self_cwd
|
||||
});
|
||||
console.log(stdout);
|
||||
}
|
||||
|
||||
async function runRelease() {
|
||||
const semanticRelease = await import('semantic-release');
|
||||
const result = await semanticRelease.default(
|
||||
{
|
||||
plugins: packageJson.release.plugins,
|
||||
dryRun: process.env.CI ? false : true,
|
||||
},
|
||||
);
|
||||
// console.debug(`nextRelease.version :>> `, nextRelease.version);
|
||||
// if (process.env.GITHUB_OUTPUT) fs.writeFileSync(process.env.GITHUB_OUTPUT, `NEXT_RELEASE_VERSION=${nextRelease.version}`);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (process.env.CI) await installDependencies();
|
||||
await runRelease();
|
31
package.json
Normal file
31
package.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"private": false,
|
||||
"packageManager": "pnpm@9.11.0",
|
||||
"name": "@murielmay67-1/semantic-release-example",
|
||||
"files": [],
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@types/node": "^22.7.4",
|
||||
"semantic-release": "^24.1.2"
|
||||
},
|
||||
"renovate": {
|
||||
"extends": [
|
||||
"https://git.1-h.cc/examples/renovate-example/raw/branch/main/default.json5"
|
||||
],
|
||||
"dependencyDashboard": false
|
||||
},
|
||||
"release": {
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/changelog",
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
2391
pnpm-lock.yaml
generated
Normal file
2391
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
run.mjs
Normal file
38
run.mjs
Normal file
@ -0,0 +1,38 @@
|
||||
const semanticRelease = await import('semantic-release');
|
||||
const prepareChangelog = await import('@semantic-release/changelog/lib/prepare.js');
|
||||
import getLogger from "semantic-release/lib/get-logger.js";
|
||||
import { tag } from "semantic-release/lib/git.js";
|
||||
import fs from 'node:fs';
|
||||
|
||||
// https://github.com/semantic-release/semantic-release/blob/master/index.js
|
||||
// https://github.dev/semantic-release/npm
|
||||
|
||||
console.debug(`!!result :>> `, !!result);
|
||||
console.log('#############################')
|
||||
|
||||
if (result !== false) {
|
||||
// console.debug(`result.nextRelease :>> `, result.nextRelease);
|
||||
// console.debug(`result :>> `, result);
|
||||
// console.debug(`result.nextRelease.notes :>> `, result.nextRelease.notes);
|
||||
// console.debug(`result.nextRelease.version :>> `, result.nextRelease.version);
|
||||
// console.debug(`result.nextRelease.gitTag :>> `, result.nextRelease.gitTag);
|
||||
// console.debug(`result.nextRelease.gitHead :>> `, result.nextRelease.gitHead);
|
||||
// fs.writeFileSync(process.env.GITHUB_OUTPUT, `matrix=${JSON.stringify(matrix)}`);
|
||||
|
||||
const { nextRelease } = result;
|
||||
// const context = {
|
||||
// cwd: process.cwd(),
|
||||
// nextRelease: result.nextRelease,
|
||||
// logger: getLogger({ stdout: process.stdout, stderr: process.stderr }),
|
||||
// }
|
||||
// await prepareChangelog.default({}, context);
|
||||
console.debug(`nextRelease.version :>> `, nextRelease.version);
|
||||
if (process.env.GITHUB_OUTPUT) fs.writeFileSync(process.env.GITHUB_OUTPUT, `NEXT_RELEASE_VERSION=${nextRelease.version}`);
|
||||
|
||||
// await tag(nextRelease.gitTag, nextRelease.gitHead); // git tag -d v2.0.0
|
||||
/*
|
||||
export async function tag(tagName, ref, execaOptions) {
|
||||
await execa("git", ["tag", tagName, ref], execaOptions);
|
||||
}
|
||||
*/
|
||||
}
|
Reference in New Issue
Block a user