Initial commit

This commit is contained in:
严浩
2024-10-11 15:55:27 +08:00
commit 2466f5a927
9 changed files with 115 additions and 0 deletions

38
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,38 @@
name: 持续集成
on:
push:
branches:
- main
env:
TZ: Asia/Shanghai
jobs:
release:
outputs:
next_release_published: ${{ steps.semantic.outputs.next_release_published }}
next_release_version: ${{ steps.semantic.outputs.next_release_version }}
runs-on: ubuntu-latest
permissions: # Job-level permissions configuration starts here
contents: write # 'write' access to repository contents
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: yanhao98/semantic-release-action@main
id: semantic
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
after-release:
runs-on: ubuntu-latest
needs: release
steps:
- name: Print
run: |
echo "next_release_published: ${{ needs.release.outputs.next_release_published }}"
echo "next_release_version: ${{ needs.release.outputs.next_release_version }}"
- uses: actions/checkout@v4
with:
ref: main
- run: cat CHANGELOG.md

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store
node_modules

1
.npmrc Normal file
View File

@ -0,0 +1 @@
shamefully-hoist=true

16
.releaserc.yaml Normal file
View File

@ -0,0 +1,16 @@
---
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
- - "@semantic-release/npm" # https://github.com/semantic-release/npm?tab=readme-ov-file#environment-variables
# [provenance](https://docs.npmjs.com/generating-provenance-statements#using-third-party-package-publishing-tools)
- npmPublish: true
- - "@semantic-release/git"
- message: |-
chore(release): ${nextRelease.version} [skip ci]
${nextRelease.notes}
- - "@semantic-release/exec"
- prepareCmd: echo 'prepareCmd'
publishCmd: echo 'publishCmd'

0
files/pr1 Normal file
View File

0
files/pr2 Normal file
View File

16
package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "semantic-release-example-24",
"description": "An example project to demonstrate semantic-release",
"version": "1.10.0",
"files": [
"CHANGELOG.md"
],
"scripts": {},
"license": "MIT",
"repository": {
"url": "git+https://github.com/yanhao98/semantic-release-action-example.git"
},
"publishConfig": {
"provenance": true
}
}

19
scripts/01.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
git switch main
commit_types=(
"feat: 一项新功能"
"fix: 错误修复"
"docs: 仅更改文档"
"style: 不影响代码含义的更改(空格、格式、缺少分号等)"
"refactor: 既不修复错误也不添加功能的代码更改"
"perf: 提高性能的代码更改"
"test: 添加缺失的或纠正现有的测试"
"chore: 对构建过程或辅助工具和库(例如文档生成)的更改"
)
i=1
for commit_type in "${commit_types[@]}"; do
git commit --allow-empty -m "$commit_type $i. $(date) on $(git rev-parse --abbrev-ref HEAD)"
((i++))
done
git push origin main:main

23
scripts/02.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
rm -f CHANGELOG.md
git fetch
latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
git tag -l | xargs -I {} git push origin :refs/tags/{}
git tag -l | xargs git tag -d
git switch main
git checkout --orphan temp_branch
git add .
git commit -m "Initial commit"
git branch -D main
git branch -m main
git branch --set-upstream-to=origin/main main
for branch in $(git branch | grep -v "main"); do
git push origin --delete "$branch"
git branch -D "$branch"
done
git push -f origin main
git tag "$latest_tag"
git push origin "$latest_tag"