From be477a7cd3e42b7f7d5642ba08ab80e2e04d0108 Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Tue, 26 Dec 2023 10:01:51 +0800 Subject: [PATCH] fix --- .github/workflows/nightly.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ec5466f..1b25ea1 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -3,6 +3,9 @@ name: Nightly Build on: schedule: - cron: '0,15,30,45 * * * * *' # This schedule runs every night at midnight UTC + push: + tags: + - "v*.*.*" jobs: nightly: @@ -16,18 +19,26 @@ jobs: - name: Prepare release body run: | + if [[ ${{ github.ref }} =~ ^refs/tags/(.*) ]]; then + RELEASE_TAG=${BASH_REMATCH[1]} + else + RELEASE_TAG=nightly + fi + echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV RELEASE_DATETIME=$(date --rfc-3339=seconds) cat < release_template.md - Release created at $RELEASE_DATETIME + Release $RELEASE_TAG created from $GITHUB_SHA at $RELEASE_DATETIME EOF envsubst < release_template.md > release_body.md - name: Build source tarball run: git archive --format=tar HEAD | gzip > archive.tgz - - name: Remove existing tag + - name: Remove existing mutalbe tag "nightly" # https://github.com/softprops/action-gh-release/issues/171 run: git push origin :refs/tags/nightly || true + # https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution + if: $RELEASE_TAG == "nightly" - name: Create or overwrite a releae # https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release @@ -35,7 +46,7 @@ jobs: with: token: ${{ secrets.MY_GITHUB_TOKEN }} # Use the secret as an environment variable prerelease: true - tag_name: nightly + tag_name: $RELEASE_TAG # The body field does not support environment variable substitution directly. body_path: release_body.md files: |