From 8cc55b3585b47f03b13a60d1931cddaee0d259ae Mon Sep 17 00:00:00 2001 From: David-Han48 Date: Wed, 31 Jul 2024 11:59:03 +0800 Subject: [PATCH 1/6] add github actions auto release workflow logic --- .github/workflows/release.yml | 194 ++++++++++++++++++++++++++++++++-- 1 file changed, 186 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f8f266ac..19375ae4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,9 @@ on: target_commitish: required: true type: string + schedule: + - cron: '30 15 * * 1' # 15:30 Mon + - cron: '30 15 * * 4' # 15:30 Thu permissions: contents: write @@ -22,33 +25,208 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/setup-go@v4 with: - go-version: "1.22.0" - - name: set version + go-version: "1.22.x" + + - name: check correct week + id: check_week + run: | + day_of_week=$(date +%u) + week_number=$(( ($(date +%s) / (60*60*24*7)) % 2 )) + if [ "$day_of_week" -eq 1 ] && [ "$week_number" -eq 0 ]; then + echo "::set-output name=RUN_WORKFLOW::true" + else if [ "$day_of_week" -eq 4 ] && [ "$week_number" -eq 1 ]; then + echo "::set-output name=RUN_WORKFLOW::true" + else + echo "::set-output name=RUN_WORKFLOW::false" + fi + + - name: set up git + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: get latest tag + if: github.event_name != 'workflow_dispatch' && steps.check_week.outputs.RUN_WORKFLOW == 'true' + id: get_latest_tag + run: | + git fetch --tags + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "::set-output name=LATEST_TAG::${latest_tag}" + + - name: set version by manual + if: github.event_name == 'workflow_dispatch' && steps.check_week.outputs.RUN_WORKFLOW == 'true' + id: set_version + run: | + new_tag="${{ github.event.inputs.tag_name }}" + current_tag="${{ github.event.inputs.previous_tag_name }}" + echo "NEW_TAG=${new_tag}" >> "$GITHUB_ENV" + echo "PREVIOUS_TAG=${current_tag}" >> "$GITHUB_ENV" + env: + GITHUB_ENV: ${{ env.GITHUB_ENV }} + + - name: set version by automatic + if: github.event_name != 'workflow_dispatch' && steps.check_week.outputs.RUN_WORKFLOW == 'true' + id: set_version_auto + run: | + current_tag="${{ steps.get_latest_tag.outputs.LATEST_TAG }}" + current_version=$(echo "${current_tag}" | cut -d'.' -f2) + next_version=$((current_version + 1)) + day_of_week=$(date +%u) + if [ "$day_of_week" -eq 1 ]; then + new_tag="v0.${next_version}.0-rc1" + else + new_tag="v0.${next_version}.0" + fi + echo "NEW_TAG=${new_tag}" >> "$GITHUB_ENV" + echo "PREVIOUS_TAG=${current_tag}" >> "$GITHUB_ENV" + env: + GITHUB_ENV: ${{ env.GITHUB_ENV }} + + - name: parse env (for scheduled runs) + if: github.event_name != 'workflow_dispatch' && steps.check_week.outputs.RUN_WORKFLOW == 'true' run: | - echo "VERSION=$(echo "${{inputs.tag_name}}" | cut -d '-' -f1)" >> "$GITHUB_ENV" + current_tag="${{ steps.get_latest_tag.outputs.LATEST_TAG }}" + current_version=$(echo "${current_tag}" | cut -d'.' -f2) + next_version=$((current_version + 1)) + new_tag="v0.${next_version}.0" + echo "VERSION=${new_tag}" >> "$GITHUB_ENV" + echo "PREVIOUS_TAG=${current_tag}" >> "$GITHUB_ENV" + echo "Print env:VERSION and env:PREVIOUS_TAG" + echo "VERSION=${new_tag}" + echo "PREVIOUS_TAG=${current_tag}" - name: generate changelog + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' run: | set -e + target_commitish="${{ github.event.inputs.target_commitish || 'main' }}" response=$(curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/Edgenesis/shifu/releases/generate-notes \ - -d '{"tag_name":"${{inputs.tag_name}}","target_commitish":"${{inputs.target_commitish}}","previous_tag_name":"${{inputs.previous_tag_name}}"}') + -d '{"tag_name":"${{ env.NEW_TAG }}","target_commitish":"'"${target_commitish}"'","previous_tag_name":"${{ env.PREVIOUS_TAG }}"}') echo $response go run tools/release/release.go "$response" env: AZURE_OPENAI_APIKEY: ${{ secrets.AZURE_OPENAI_APIKEY }} AZURE_OPENAI_HOST: ${{ secrets.AZURE_OPENAI_HOST }} DEPLOYMENT_NAME: ${{secrets.DEPLOYMENT_NAME}} + GITHUB_ENV: ${{ env.GITHUB_ENV }} + - name: Create Pull Request + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' uses: peter-evans/create-pull-request@v5 with: - commit-message: add changelog for ${{env.VERSION}} - title: add changelog for ${{env.VERSION}} - body: add changelog for ${{env.VERSION}} - branch: changelog-${{env.VERSION}} + commit-message: add changelog for ${{ env.NEW_TAG }} + title: add changelog for ${{ env.NEW_TAG }} + body: add changelog for ${{ env.NEW_TAG }} + branch: changelog-${{ env.NEW_TAG }} base: main + + - name: Fetch Pull Request Number + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + id: get-pr + run: | + PR_NUMBER=$(gh pr list --base main --head changelog-${{ env.NEW_TAG }} --json number --jq '.[0].number') + echo $PR_NUMBER + echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Merge Pull Request + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + run: | + gh pr merge ${{ env.PR_NUMBER }} --auto --merge + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: read changelog content + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + id: read_changelog + run: | + echo ${{ env.NEW_TAG }} + changelog_file="CHANGELOG/testChangelog" + changelog_file="CHANGELOG/CHANGELOG-${new_tag}.md" + changelog_file_zh="CHANGELOG/CHANGELOG-${new_tag}-zh.md" + if [ -f "$changelog_file" ]; then + changelog_content=$(cat $changelog_file) + else + echo "Changelog file not found: $changelog_file" + exit 1 + fi + if [ -f "$changelog_file_zh" ]; then + changelog_content_zh=$(cat $changelog_file_zh) + else + echo "Changelog file not found: $changelog_file_zh" + exit 1 + fi + combined_changelog="${changelog_content}\n\n${changelog_content_zh}" + echo "::set-output name=CHANGELOG_CONTENT::${combined_changelog}" + + - name: checkout main branch + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + run: | + git checkout main + git pull + + - name: create local branch + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + run: | + new_tag="${{ env.NEW_TAG }}" + branch_name="release_${new_tag}" + git checkout -b $branch_name + echo "BRANCH_NAME=${branch_name}" >> "$GITHUB_ENV" + + - name: make tag + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + run: | + new_tag="${{ env.NEW_TAG }}" + make tag VERSION="${new_tag}" + echo "BRANCH NAME = ${{ env.BRANCH_NAME }}" + git commit -am "change tag for release ${new_tag}" + echo "BEFORE TAG" + git show-ref + git tag ${new_tag} + echo "AFTER TAG" + git show-ref + git push origin ${new_tag} + git push origin "release_${new_tag}" + + - name: determine if pre-release + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + id: determine_pre_release + run: | + day_of_week=$(date +%u) + if [ "$day_of_week" -eq 4 ]; then + echo "::set-output name=PRE_RELEASE::true" + else + echo "::set-output name=PRE_RELEASE::false" + fi + + - name: create release + if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + run: | + release_tag="${{ env.NEW_TAG }}" + echo ${release_tag} + changelog_content="${{ steps.read_changelog.outputs.CHANGELOG_CONTENT }}" + echo ${changelog_content} + pre_release="${{ steps.determine_pre_release.outputs.PRE_RELEASE }}" + if [ "$pre_release" == "true" ]; then + gh release create $release_tag \ + --target main \ + --title "$release_tag" \ + --notes "$changelog_content" \ + --prerelease + else + gh release create $release_tag \ + --target main \ + --title "$release_tag" \ + --notes "$changelog_content" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b9e6ba42f9477036bc6143a32c6b7d425d6dc668 Mon Sep 17 00:00:00 2001 From: David-Han48 Date: Wed, 31 Jul 2024 14:23:09 +0800 Subject: [PATCH 2/6] add build.yml --- .github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++++ .github/workflows/codecov.yml | 8 +++---- 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..5695eaadb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: build + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.22.x' + cache-dependency-path: go.sum + - name: Install dependencies + run: | + go mod tidy -v + sudo apt-get install libpcap-dev docker docker-compose + - name: Build executable files + run: | + make build + - name: build images + run: | + make buildx-build-image-deviceshifu + make buildx-push-image-deviceshifu + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Build artifacts + path: | + + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: ${{ github.event.head_commit.message }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 57238f857..3e6b8bae9 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -13,17 +13,17 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v5 with: - go-version: "1.22.0" + go-version: "1.22.x" - name: Install pcap run: sudo apt-get install libpcap-dev - name: Run coverage run: make test - name: Codecov - uses: codecov/codecov-action@v3.1.0 + uses: codecov/codecov-action@v3.1.5 with: files: ./coverage_tdengine.out,./coverage.out name: codecov-shifu fail_ci_if_error: true - verbose: true + verbose: true \ No newline at end of file From 7087631fa60f1f90de7b929748cbd9b8ee026f0d Mon Sep 17 00:00:00 2001 From: David-Han48 Date: Thu, 1 Aug 2024 01:17:48 +0800 Subject: [PATCH 3/6] fix PR comments --- .github/workflows/release.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 19375ae4c..0fd46d421 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,8 +13,7 @@ on: required: true type: string schedule: - - cron: '30 15 * * 1' # 15:30 Mon - - cron: '30 15 * * 4' # 15:30 Thu + - cron: '30 15 * * 1,3' # 15:30 Mon, Wed permissions: contents: write @@ -57,7 +56,7 @@ jobs: latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) echo "::set-output name=LATEST_TAG::${latest_tag}" - - name: set version by manual + - name: manually set version if: github.event_name == 'workflow_dispatch' && steps.check_week.outputs.RUN_WORKFLOW == 'true' id: set_version run: | @@ -68,7 +67,7 @@ jobs: env: GITHUB_ENV: ${{ env.GITHUB_ENV }} - - name: set version by automatic + - name: automatically set version if: github.event_name != 'workflow_dispatch' && steps.check_week.outputs.RUN_WORKFLOW == 'true' id: set_version_auto run: | @@ -133,7 +132,6 @@ jobs: id: get-pr run: | PR_NUMBER=$(gh pr list --base main --head changelog-${{ env.NEW_TAG }} --json number --jq '.[0].number') - echo $PR_NUMBER echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -149,7 +147,6 @@ jobs: if: steps.check_week.outputs.RUN_WORKFLOW == 'true' id: read_changelog run: | - echo ${{ env.NEW_TAG }} changelog_file="CHANGELOG/testChangelog" changelog_file="CHANGELOG/CHANGELOG-${new_tag}.md" changelog_file_zh="CHANGELOG/CHANGELOG-${new_tag}-zh.md" @@ -189,11 +186,7 @@ jobs: make tag VERSION="${new_tag}" echo "BRANCH NAME = ${{ env.BRANCH_NAME }}" git commit -am "change tag for release ${new_tag}" - echo "BEFORE TAG" - git show-ref git tag ${new_tag} - echo "AFTER TAG" - git show-ref git push origin ${new_tag} git push origin "release_${new_tag}" From 400d884f7cb89a369475d1d927920143dd48a769 Mon Sep 17 00:00:00 2001 From: David-Han48 Date: Fri, 2 Aug 2024 15:53:18 +0800 Subject: [PATCH 4/6] split into 3 files --- .github/workflows/create-release.yaml | 77 ++++++++++++++++ .github/workflows/handle-merge.yaml | 91 ++++++++++++++++++ .github/workflows/release.yml | 127 +++----------------------- 3 files changed, 183 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/create-release.yaml create mode 100644 .github/workflows/handle-merge.yaml diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml new file mode 100644 index 000000000..929a4c607 --- /dev/null +++ b/.github/workflows/create-release.yaml @@ -0,0 +1,77 @@ +name: Publish Release + +on: + workflow_dispatch: + +jobs: + publish_release: + runs-on: ubuntu-latest + + steps: + - name: checkout code + uses: actions/checkout@v2 + + - name: set up Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: get latest tag + id: get_latest_tag + run: | + git fetch --tags + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "::set-output name=LATEST_TAG::${latest_tag}" + env: + GITHUB_ENV: ${{ env.GITHUB_ENV }} + + - name: set version + id: set_version_auto + run: | + current_tag="${{ steps.get_latest_tag.outputs.LATEST_TAG }}" + current_tag=${current_tag#v} + if [[ "$current_tag" == *"-rc1" ]]; then + current_tag=${current_tag%-rc1} + fi + IFS='.' read -r x y z <<< "$current_tag" + y=$((y + 1)) + day_of_week=$(date +%u) + if [ "$day_of_week" -eq 1 ]; then + new_tag="v${x}.${y}.${z}" + else + new_tag="v${x}.${y}.${z}-rc1" + fi + echo "NEW_TAG=${new_tag}" >> "$GITHUB_ENV" + env: + GITHUB_ENV: ${{ env.GITHUB_ENV }} + + - name: determine if pre-release + id: determine_pre_release + run: | + day_of_week=$(date +%u) + if [ "$day_of_week" -eq 3 ]; then + echo "::set-output name=PRE_RELEASE::true" + else + echo "::set-output name=PRE_RELEASE::false" + fi + + - name: create release + run: | + release_tag="${{ env.NEW_TAG }}" + changelog_content="""## See [CHANGELOG-v0.x.0.md](CHANGELOG/CHANGELOG-v0.x.0.md) for details + ## 详细内容请查看 [CHANGELOG-v0.x.0-zh.md](CHANGELOG/CHANGELOG-v0.x.0-zh.md)""" + pre_release="${{ steps.determine_pre_release.outputs.PRE_RELEASE }}" + if [ "$pre_release" == "true" ]; then + gh release create "$release_tag" \ + --target main \ + --title "$release_tag" \ + --generate-notes \ + --prerelease + else + gh release create "$release_tag" \ + --target main \ + --title "$release_tag" \ + --notes "$changelog_content" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/handle-merge.yaml b/.github/workflows/handle-merge.yaml new file mode 100644 index 000000000..f7b11a37f --- /dev/null +++ b/.github/workflows/handle-merge.yaml @@ -0,0 +1,91 @@ +name: Create Tag + +on: + workflow_dispatch: + +jobs: + handle_merged_pr: + runs-on: ubuntu-latest + + steps: + - name: checkout code + uses: actions/checkout@v2 + + - uses: actions/setup-go@v4 + with: + go-version: "1.22.x" + + - name: set up git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: get latest tag + id: get_latest_tag + run: | + git fetch --tags + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "::set-output name=LATEST_TAG::${latest_tag}" + env: + GITHUB_ENV: ${{ env.GITHUB_ENV }} + + - name: set version + id: set_version_auto + run: | + current_tag="${{ steps.get_latest_tag.outputs.LATEST_TAG }}" + current_tag=${current_tag#v} + if [[ "$current_tag" == *"-rc1" ]]; then + current_tag=${current_tag%-rc1} + fi + IFS='.' read -r x y z <<< "$current_tag" + y=$((y + 1)) + day_of_week=$(date +%u) + if [ "$day_of_week" -eq 1 ]; then + new_tag="v${x}.${y}.${z}" + else + new_tag="v${x}.${y}.${z}-rc1" + fi + echo "NEW_TAG=${new_tag}" >> "$GITHUB_ENV" + env: + GITHUB_ENV: ${{ env.GITHUB_ENV }} + + - name: read changelog content + id: read_changelog + run: | + changelog_file="CHANGELOG/CHANGELOG-${new_tag}.md" + changelog_file_zh="CHANGELOG/CHANGELOG-${new_tag}-zh.md" + if [ -f "$changelog_file" ]; then + changelog_content=$(cat $changelog_file) + else + echo "Changelog file not found: $changelog_file" + exit 1 + fi + if [ -f "$changelog_file_zh" ]; then + changelog_content_zh=$(cat $changelog_file_zh) + else + echo "Changelog file not found: $changelog_file_zh" + exit 1 + fi + combined_changelog="${changelog_content}\n\n${changelog_content_zh}" + echo "::set-output name=CHANGELOG_CONTENT::${combined_changelog}" + + - name: make tag + run: | + git checkout main + git pull + git checkout -b "local_release${{ env.NEW_TAG }}" + make tag VERSION="${{ env.NEW_TAG }}" + git commit -am "change tag for release ${{ env.NEW_TAG }}" + git push origin HEAD + env: + GITHUB_ENV: ${{ env.GITHUB_ENV }} + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + commit-message: change tag for release ${{ env.NEW_TAG }} + title: change tag for release ${{ env.NEW_TAG }} + body: change tag for release ${{ env.NEW_TAG }} + branch: local_release${{ env.NEW_TAG }} + base: release_${{ env.NEW_TAG }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fd46d421..344070a32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,4 @@ + name: Auto Generate Release Log on: @@ -36,7 +37,7 @@ jobs: week_number=$(( ($(date +%s) / (60*60*24*7)) % 2 )) if [ "$day_of_week" -eq 1 ] && [ "$week_number" -eq 0 ]; then echo "::set-output name=RUN_WORKFLOW::true" - else if [ "$day_of_week" -eq 4 ] && [ "$week_number" -eq 1 ]; then + elif [ "$day_of_week" -eq 3 ] && [ "$week_number" -eq 1 ]; then echo "::set-output name=RUN_WORKFLOW::true" else echo "::set-output name=RUN_WORKFLOW::false" @@ -63,7 +64,6 @@ jobs: new_tag="${{ github.event.inputs.tag_name }}" current_tag="${{ github.event.inputs.previous_tag_name }}" echo "NEW_TAG=${new_tag}" >> "$GITHUB_ENV" - echo "PREVIOUS_TAG=${current_tag}" >> "$GITHUB_ENV" env: GITHUB_ENV: ${{ env.GITHUB_ENV }} @@ -72,31 +72,22 @@ jobs: id: set_version_auto run: | current_tag="${{ steps.get_latest_tag.outputs.LATEST_TAG }}" - current_version=$(echo "${current_tag}" | cut -d'.' -f2) - next_version=$((current_version + 1)) + current_tag=${current_tag#v} + if [[ "$current_tag" == *"-rc1" ]]; then + current_tag=${current_tag%-rc1} + fi + IFS='.' read -r x y z <<< "$current_tag" + y=$((y + 1)) day_of_week=$(date +%u) if [ "$day_of_week" -eq 1 ]; then - new_tag="v0.${next_version}.0-rc1" + new_tag="v${x}.${y}.${z}" else - new_tag="v0.${next_version}.0" + new_tag="v${x}.${y}.${z}-rc1" fi echo "NEW_TAG=${new_tag}" >> "$GITHUB_ENV" - echo "PREVIOUS_TAG=${current_tag}" >> "$GITHUB_ENV" env: GITHUB_ENV: ${{ env.GITHUB_ENV }} - - name: parse env (for scheduled runs) - if: github.event_name != 'workflow_dispatch' && steps.check_week.outputs.RUN_WORKFLOW == 'true' - run: | - current_tag="${{ steps.get_latest_tag.outputs.LATEST_TAG }}" - current_version=$(echo "${current_tag}" | cut -d'.' -f2) - next_version=$((current_version + 1)) - new_tag="v0.${next_version}.0" - echo "VERSION=${new_tag}" >> "$GITHUB_ENV" - echo "PREVIOUS_TAG=${current_tag}" >> "$GITHUB_ENV" - echo "Print env:VERSION and env:PREVIOUS_TAG" - echo "VERSION=${new_tag}" - echo "PREVIOUS_TAG=${current_tag}" - name: generate changelog if: steps.check_week.outputs.RUN_WORKFLOW == 'true' run: | @@ -126,100 +117,12 @@ jobs: body: add changelog for ${{ env.NEW_TAG }} branch: changelog-${{ env.NEW_TAG }} base: main - - - name: Fetch Pull Request Number - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' - id: get-pr - run: | - PR_NUMBER=$(gh pr list --base main --head changelog-${{ env.NEW_TAG }} --json number --jq '.[0].number') - echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Merge Pull Request - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' - run: | - gh pr merge ${{ env.PR_NUMBER }} --auto --merge - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: read changelog content - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' - id: read_changelog - run: | - changelog_file="CHANGELOG/testChangelog" - changelog_file="CHANGELOG/CHANGELOG-${new_tag}.md" - changelog_file_zh="CHANGELOG/CHANGELOG-${new_tag}-zh.md" - if [ -f "$changelog_file" ]; then - changelog_content=$(cat $changelog_file) - else - echo "Changelog file not found: $changelog_file" - exit 1 - fi - if [ -f "$changelog_file_zh" ]; then - changelog_content_zh=$(cat $changelog_file_zh) - else - echo "Changelog file not found: $changelog_file_zh" - exit 1 - fi - combined_changelog="${changelog_content}\n\n${changelog_content_zh}" - echo "::set-output name=CHANGELOG_CONTENT::${combined_changelog}" - - - name: checkout main branch - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' + + - name: make release branch run: | git checkout main git pull - - - name: create local branch - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' - run: | - new_tag="${{ env.NEW_TAG }}" - branch_name="release_${new_tag}" - git checkout -b $branch_name - echo "BRANCH_NAME=${branch_name}" >> "$GITHUB_ENV" - - - name: make tag - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' - run: | - new_tag="${{ env.NEW_TAG }}" - make tag VERSION="${new_tag}" - echo "BRANCH NAME = ${{ env.BRANCH_NAME }}" - git commit -am "change tag for release ${new_tag}" - git tag ${new_tag} - git push origin ${new_tag} - git push origin "release_${new_tag}" - - - name: determine if pre-release - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' - id: determine_pre_release - run: | - day_of_week=$(date +%u) - if [ "$day_of_week" -eq 4 ]; then - echo "::set-output name=PRE_RELEASE::true" - else - echo "::set-output name=PRE_RELEASE::false" - fi - - - name: create release - if: steps.check_week.outputs.RUN_WORKFLOW == 'true' - run: | - release_tag="${{ env.NEW_TAG }}" - echo ${release_tag} - changelog_content="${{ steps.read_changelog.outputs.CHANGELOG_CONTENT }}" - echo ${changelog_content} - pre_release="${{ steps.determine_pre_release.outputs.PRE_RELEASE }}" - if [ "$pre_release" == "true" ]; then - gh release create $release_tag \ - --target main \ - --title "$release_tag" \ - --notes "$changelog_content" \ - --prerelease - else - gh release create $release_tag \ - --target main \ - --title "$release_tag" \ - --notes "$changelog_content" - fi + git checkout -b "release_${{ env.NEW_TAG }}" + git push origin HEAD env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_ENV: ${{ env.GITHUB_ENV }} \ No newline at end of file From 2b925522dbc2ee1b88876a1297b3db9d3ed7d254 Mon Sep 17 00:00:00 2001 From: David-Han48 Date: Fri, 2 Aug 2024 16:09:05 +0800 Subject: [PATCH 5/6] remove build.yml --- .github/workflows/build.yml | 45 ------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 5695eaadb..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,45 +0,0 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - -name: build - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: '1.22.x' - cache-dependency-path: go.sum - - name: Install dependencies - run: | - go mod tidy -v - sudo apt-get install libpcap-dev docker docker-compose - - name: Build executable files - run: | - make build - - name: build images - run: | - make buildx-build-image-deviceshifu - make buildx-push-image-deviceshifu - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: Build artifacts - path: | - - - name: Create Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - body: ${{ github.event.head_commit.message }} - draft: false - prerelease: false \ No newline at end of file From 8f8597dfa0c620241963ac3855b156c32b42dacd Mon Sep 17 00:00:00 2001 From: David-Han48 Date: Fri, 2 Aug 2024 16:10:22 +0800 Subject: [PATCH 6/6] add EOF --- .github/workflows/codecov.yml | 2 +- .github/workflows/create-release.yaml | 2 +- .github/workflows/handle-merge.yaml | 1 - .github/workflows/release.yml | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 3e6b8bae9..8bf7be10e 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -26,4 +26,4 @@ jobs: files: ./coverage_tdengine.out,./coverage.out name: codecov-shifu fail_ci_if_error: true - verbose: true \ No newline at end of file + verbose: true diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 929a4c607..2527589a0 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -74,4 +74,4 @@ jobs: --notes "$changelog_content" fi env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/handle-merge.yaml b/.github/workflows/handle-merge.yaml index f7b11a37f..40eba1b2e 100644 --- a/.github/workflows/handle-merge.yaml +++ b/.github/workflows/handle-merge.yaml @@ -88,4 +88,3 @@ jobs: body: change tag for release ${{ env.NEW_TAG }} branch: local_release${{ env.NEW_TAG }} base: release_${{ env.NEW_TAG }} - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 344070a32..7667b23e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -125,4 +125,4 @@ jobs: git checkout -b "release_${{ env.NEW_TAG }}" git push origin HEAD env: - GITHUB_ENV: ${{ env.GITHUB_ENV }} \ No newline at end of file + GITHUB_ENV: ${{ env.GITHUB_ENV }}