From 32c610a7b0727965d26f0245242df6e87888d75b Mon Sep 17 00:00:00 2001 From: cuisongliu Date: Sat, 18 Nov 2023 12:09:43 +0800 Subject: [PATCH] docs(main): auto release node using just Signed-off-by: cuisongliu --- .../workflows/{release.yml => release.yaml} | 1 + .github/workflows/tagpr.yaml | 29 ++++++++++++ .github/workflows/update_version_config.yaml | 45 +++++++++++++++++++ .tagpr | 7 +++ justfile | 5 +++ 5 files changed, 87 insertions(+) rename .github/workflows/{release.yml => release.yaml} (99%) create mode 100644 .github/workflows/tagpr.yaml create mode 100644 .github/workflows/update_version_config.yaml create mode 100644 .tagpr diff --git a/.github/workflows/release.yml b/.github/workflows/release.yaml similarity index 99% rename from .github/workflows/release.yml rename to .github/workflows/release.yaml index 6226ef05d1..7c9070e99c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yaml @@ -3,6 +3,7 @@ name: 🚀 Release on: push: tags: ["v[0-9]+.[0-9]+.[0-9]+*"] + workflow_dispatch: jobs: build: diff --git a/.github/workflows/tagpr.yaml b/.github/workflows/tagpr.yaml new file mode 100644 index 0000000000..48c8992a1c --- /dev/null +++ b/.github/workflows/tagpr.yaml @@ -0,0 +1,29 @@ +name: 🚀 Tagpr for GitHub Actions +on: + push: + branches: + - main +jobs: + tagpr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Install just + uses: taiki-e/install-action@just + - uses: Songmu/tagpr@v1 + id: tagpr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Trigger Release Workflow(only when tagged) + uses: actions/github-script@v6 + if: "steps.tagpr.outputs.tag != '' && steps.tagpr.outputs.tag != 'v0.3.0'" + with: + script: | + github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'release.yaml', + ref: "refs/tags/${{ steps.tagpr.outputs.tag }}", + }) \ No newline at end of file diff --git a/.github/workflows/update_version_config.yaml b/.github/workflows/update_version_config.yaml new file mode 100644 index 0000000000..d301010ef0 --- /dev/null +++ b/.github/workflows/update_version_config.yaml @@ -0,0 +1,45 @@ +name: 🤖 Automated Update tagpr config + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release' + required: true + default: '0.3.0' +jobs: + config: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Update tagpr config + run: | + cat << EOF > .tagpr + [tagpr] + vPrefix = true + releaseBranch = main + versionFile = justfile + command = just version-up ${{ github.event.inputs.version }} + release = false + changelog = true + EOF + - uses: peter-evans/create-pull-request@v5 + with: + title: 'config: Automated Tagpr Update for ${{ github.event.inputs.version }}' + add-paths: | + .tagpr + body: | + + Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action + commit-message: | + 🤖 update tagpr config using robot. + branch: tagpr-${{ github.event.inputs.version }} + base: main + signoff: true + delete-branch: true + token: ${{ secrets.GITHUB_TOKEN }} + committer: github-actions[bot] + author: github-actions[bot] diff --git a/.tagpr b/.tagpr new file mode 100644 index 0000000000..862310715c --- /dev/null +++ b/.tagpr @@ -0,0 +1,7 @@ +[tagpr] + vPrefix = true + releaseBranch = main + versionFile = justfile + command = just version-up 0.3.0 + release = false + changelog = true \ No newline at end of file diff --git a/justfile b/justfile index 321d580a68..1cf8dd10b4 100644 --- a/justfile +++ b/justfile @@ -190,6 +190,11 @@ ci-musl-prepare: ci-prepare exit 1 version-up version: + #!/usr/bin/bash + set -ex + if [[ "{{version}}" == "0.3.0" ]]; then + return + fi git grep -l "^version = .* # MARK: Version" | xargs sed -i 's/version = "[0-9]\.[0-9]\.[0-9]" # MARK: Version/version = "{{version}}" # MARK: Version/g' git grep -l "} # MARK: Version" | grep -v justfile | xargs sed -i 's/version = "[0-9]\.[0-9]\.[0-9]" } # MARK: Version/version = "{{version}}" } # MARK: Version/g' {{ cwd }}/scripts/release_tag.sh {{version}} \ No newline at end of file