From 1098ab312ea6d55bbf76079ddde03d6749fe04d0 Mon Sep 17 00:00:00 2001 From: Duplicate4 Date: Tue, 19 Mar 2024 08:24:37 +0800 Subject: [PATCH 1/3] chore: tag ci (#14) * chore: add tag ci Signed-off-by: Dup4 * chore: add tutorial Signed-off-by: Dup4 * chore: add tutorial Signed-off-by: Dup4 * chore: add tutorial Signed-off-by: Dup4 --------- Signed-off-by: Dup4 --- .editorconfig | 3 +++ .github/workflows/tag.yml | 30 ++++++++++++++++++++++++++++++ README.md | 6 ++++++ VERSION | 1 + 4 files changed, 40 insertions(+) create mode 100644 .github/workflows/tag.yml create mode 100644 VERSION diff --git a/.editorconfig b/.editorconfig index 911234fa4..59b80f495 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,6 @@ trim_trailing_whitespace = true charset = utf-8 indent_style = space indent_size = 4 + +[*.yml] +indent_size = 2 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 000000000..e66bd42af --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,30 @@ +name: Tag on Version Change +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check Version + id: check_version + run: | + if [[ -f VERSION ]]; then + version=$(cat VERSION) + tags=$(git tag --list) + if [[ ! "$tags" =~ (^|[[:space:]])"$version"($|[[:space:]]) ]]; then + echo "::set-output name=tag::$version" + fi + fi + + - name: Create Tag + if: steps.check_version.outputs.tag + run: | + git tag ${{ steps.check_version.outputs.tag }} + git push origin ${{ steps.check_version.outputs.tag }} diff --git a/README.md b/README.md index 32fad7bbc..0b16fd9ab 100644 --- a/README.md +++ b/README.md @@ -131,3 +131,9 @@ docker exec -it hznuoj bash [gh-release-badge]: https://img.shields.io/github/release/hznuoj-dev/hznuoj.svg [gh-release]: https://GitHub.com/hznuoj-dev/hznuoj/releases/ + +## 发布 + +* 将改动提交一个 PR +* 在 PR 中,修改 VERSION 中的版本号,版本号要满足 `vx.x.x` 的格式,如果能满足 [语义化版本](https://semver.org/lang/zh-CN/) 的话更好 +* 当 PR merge 到 master 的时候,如果 VERSION 里的版本号不存在于 git tag 中,那么会触发版本发布,会自动构建一个 docker image diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..77cada2e0 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.0.6 From 1106d2babbc40bc2ecc2388ddbdcba46400de0db Mon Sep 17 00:00:00 2001 From: Duplicate4 Date: Tue, 19 Mar 2024 08:28:19 +0800 Subject: [PATCH 2/3] fix: tag ci (#15) * fix: tag ci Signed-off-by: Dup4 * chore: upgrade v Signed-off-by: Dup4 --------- Signed-off-by: Dup4 --- .github/workflows/tag.yml | 2 ++ VERSION | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index e66bd42af..5ac591e7a 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -11,6 +11,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-tags: true - name: Check Version id: check_version diff --git a/VERSION b/VERSION index 77cada2e0..41a281954 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.0.6 +v0.0.7 From c0c6cb193efaa7f1d01068baf1c6472738c99062 Mon Sep 17 00:00:00 2001 From: Dup4 Date: Tue, 19 Mar 2024 08:29:20 +0800 Subject: [PATCH 3/3] style: pretty Signed-off-by: Dup4 --- .github/workflows/tag.yml | 7 +++++-- README.md | 4 ++-- VERSION | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 5ac591e7a..99edad01f 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -12,21 +12,24 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - fetch-tags: true + fetch-depth: 0 - name: Check Version id: check_version + shell: bash run: | if [[ -f VERSION ]]; then version=$(cat VERSION) tags=$(git tag --list) + echo $tags if [[ ! "$tags" =~ (^|[[:space:]])"$version"($|[[:space:]]) ]]; then + echo $version echo "::set-output name=tag::$version" fi fi - name: Create Tag - if: steps.check_version.outputs.tag + if: ${{ startsWith(steps.check_version.outputs.tag, 'v') }} run: | git tag ${{ steps.check_version.outputs.tag }} git push origin ${{ steps.check_version.outputs.tag }} diff --git a/README.md b/README.md index 0b16fd9ab..a416970c9 100644 --- a/README.md +++ b/README.md @@ -135,5 +135,5 @@ docker exec -it hznuoj bash ## 发布 * 将改动提交一个 PR -* 在 PR 中,修改 VERSION 中的版本号,版本号要满足 `vx.x.x` 的格式,如果能满足 [语义化版本](https://semver.org/lang/zh-CN/) 的话更好 -* 当 PR merge 到 master 的时候,如果 VERSION 里的版本号不存在于 git tag 中,那么会触发版本发布,会自动构建一个 docker image +* 在 PR 中,修改 [VERSION](./VERSION) 中的版本号,版本号要满足 `vx.x.x` 的格式,如果能满足 [语义化版本](https://semver.org/lang/zh-CN/) 的话更好 +* 当 PR merge 到 master 的时候,如果 [VERSION](./VERSION) 里的版本号不存在于 git tag 中,那么会触发版本发布,会自动构建一个 docker image diff --git a/VERSION b/VERSION index 41a281954..3ce186fb7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.0.7 +v0.0.8