diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index 957e694235..d692910b7b 100644 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -21,6 +21,9 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - name: Setup Go uses: actions/setup-go@v5 with: @@ -28,14 +31,36 @@ jobs: - name: Prepare environment run: | - echo "BUILD_NUMBER=${{ github.repository }}-${{ github.workflow }}-${{ github.run_id }}-ghactions" >> $GITHUB_ENV - echo "BUILD_COMMIT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV - echo "BUILD_BRANCH_SAFE=${{ github.ref }}" >> $GITHUB_ENV - echo "BUILD_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - echo "BUILD_BRANCH=${{ github.ref }}" >> $GITHUB_ENV + RELEASE_BUILD=false + if [[ "${GITHUB_REF}" == /refs/tags/* ]]; then RELEASE_BUILD=true; fi - - name: Generate env file - run: go run mage.go -v GenerateEnvFile + RC_BUILD=false + if [[ "${GITHUB_REF}" == /refs/tags/*-rc ]]; then RC_BUILD=true; fi + + SNAPSHOT_BUILD=false + if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then SNAPSHOT_BUILD=true; fi + + PR_BUILD=false + if [[ "${SNAPSHOT_BUILD}" == "false" && "${RELEASE_BUILD}" == "false" ]]; then PR_BUILD=true; fi + + BUILD_NUMBER="${{ github.run_id }}"-ghactions + + if [[ "${RELEASE_BUILD}" == "true" ]]; then + BUILD_VERSION="${GITHUB_REF#/refs/tags/}"; + elif [[ "${SNAPSHOT_BUILD}" == "true" ]]; then + BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1snapshot-"$(date '+%Y%m%dT%H%M')"-"$(echo ${GITHUB_SHA} | cut -c1-8)"; + elif [[ "${PR_BUILD}" == "true" ]]; then + BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1branch-"${GITHUB_REF_NAME}"; + fi + + echo "export RELEASE_BUILD=$RELEASE_BUILD;" >> build/env.sh + echo "export RC_BUILD=$RC_BUILD;" >> build/env.sh + echo "export SNAPSHOT_BUILD=$SNAPSHOT_BUILD;" >> build/env.sh + echo "export BUILD_NUMBER=$BUILD_NUMBER;" >> build/env.sh + echo "export BUILD_VERSION=$BUILD_VERSION;" >> build/env.sh + + # - name: Generate env file + # run: go run mage.go -v GenerateEnvFile # - name: Create bucket # if: github.event_name == 'push' diff --git a/.github/workflows/tests-and-linters.yml b/.github/workflows/tests-and-linters.yml index 1e1d6d26ba..798f8e7179 100644 --- a/.github/workflows/tests-and-linters.yml +++ b/.github/workflows/tests-and-linters.yml @@ -1,6 +1,7 @@ name: Tests -# on: +on: # pull_request: + workflow_call: env: GOFLAGS: "-count=1"