From d28fb457d1ca98ef8a07e8827fa3146b1800f55d Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Wed, 27 Dec 2023 14:59:11 +0800 Subject: [PATCH 1/2] Support trigger nightly build manually --- .github/workflows/release.yml | 44 ++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87339c26c4..eb08345926 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,9 +3,11 @@ name: release on: schedule: - cron: '0 0 * * *' # This schedule runs every night at midnight UTC - push: + # The "create tags" trigger is specifically focused on the creation of new tags, while the "push tags" trigger is activated when tags are pushed, including both new tag creations and updates to existing tags. + create: tags: - - "v*.*.*" # normal release + - "v*.*.*" # normal release + - "nightly" # the only one mutable tag jobs: release: @@ -14,17 +16,24 @@ jobs: - name: Ensure workspace ownership run: echo "chown -R $USER $GITHUB_WORKSPACE" && sudo chown -R $USER $GITHUB_WORKSPACE + # https://github.com/actions/checkout/blob/v3/README.md - name: Check out code uses: actions/checkout@v3 - name: Prepare release body run: | - if [[ ${{ github.ref }} =~ ^refs/tags/v(.*) ]]; then - RELEASE_TAG=v${BASH_REMATCH[1]} - PRERELEASE=false + if [[ $GITHUB_EVENT_NAME == 'create' ]]; then + RELEASE_TAG=${GITHUB_REF#refs/tags/} + if [[ $RELEASE_TAG == 'nightly' ]]; then + PRERELEASE=true + else + PRERELEASE=false + fi + echo "Workflow triggered by create tag: $RELEASE_TAG" else RELEASE_TAG=nightly PRERELEASE=true + echo "Workflow triggered by schedule" fi echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV @@ -34,6 +43,22 @@ jobs: EOF envsubst < release_template.md > release_body.md + - name: Move the existing mutable tag + # https://github.com/softprops/action-gh-release/issues/171 + run: | + if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then + # Determine if a given tag exists and matches a specific Git commit. + # actions/checkout@v3 fetch-tags doesn't work when triggered by schedule + git fetch --tags + if [ "$(git rev-parse -q --verify "refs/tags/$RELEASE_TAG")" = "$GITHUB_SHA" ]; then + echo "mutalbe tag $RELEASE_TAG exists and matchs $GITHUB_SHA" + else + git tag -f $RELEASE_TAG $GITHUB_SHA + git push -f origin $RELEASE_TAG:refs/tags/$RELEASE_TAG + echo "created/moved mutalbe tag $RELEASE_TAG to $GITHUB_SHA" + fi + fi + - name: Start builder container run: | TZ=$(readlink -f /etc/localtime | awk -F '/zoneinfo/' '{print $2}') @@ -45,15 +70,6 @@ jobs: - name: Build RPM and DEB run: sudo docker exec infinity_build bash -c "cd /infinity/cmake-build-release && cpack" - - name: Move the existing mutable tag - # https://github.com/softprops/action-gh-release/issues/171 - run: | - if [[ $RELEASE_TAG != v* ]]; then - echo "moving mutalbe tag $RELEASE_TAG to $GITHUB_SHA" - git tag -f $RELEASE_TAG - git push -f origin $RELEASE_TAG:refs/tags/$RELEASE_TAG - fi - - name: Create or overwrite a releae # https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release uses: softprops/action-gh-release@v1 From 5b0460425e69f3594d247318d701a1c089dafb47 Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Wed, 27 Dec 2023 15:56:46 +0800 Subject: [PATCH 2/2] Checkout repo using ssh --- .github/workflows/release.yml | 2 ++ .github/workflows/tests.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb08345926..71c7e41f86 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,8 @@ jobs: # https://github.com/actions/checkout/blob/v3/README.md - name: Check out code uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.MY_DEPLOY_KEY }} - name: Prepare release body run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f85758a8ea..3ed2bd26e2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,6 +22,8 @@ jobs: - name: Check out code uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.MY_DEPLOY_KEY }} - name: Start builder container run: |