From dd4c17972fdfef7517c22d017ec922463fb94350 Mon Sep 17 00:00:00 2001 From: tobyxdd Date: Sat, 10 Dec 2022 18:14:17 -0800 Subject: [PATCH] ci: fix build scripts to handle multi-tags --- .github/workflows/release-docker.yaml | 8 ++------ .github/workflows/release.yml | 4 ---- Taskfile.yaml | 2 +- build.ps1 | 12 ++++++------ 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release-docker.yaml b/.github/workflows/release-docker.yaml index 6bb861e29d..3fc9aca801 100644 --- a/.github/workflows/release-docker.yaml +++ b/.github/workflows/release-docker.yaml @@ -4,10 +4,6 @@ on: push: tags: - 'v*' - branches: - - master - - main - - release jobs: docker: @@ -21,7 +17,7 @@ jobs: - name: Get tag id: get_tag - run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} + run: echo "TAG=$(git describe --tags --always --match 'v*')" >> $GITHUB_OUTPUT - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -42,7 +38,7 @@ jobs: context: . push: true platforms: linux/amd64,linux/arm64 - tags: tobyxdd/hysteria:latest,tobyxdd/hysteria:${{ steps.get_tag.outputs.tag }} + tags: tobyxdd/hysteria:latest,tobyxdd/hysteria:${{ steps.get_tag.outputs.TAG }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 89b4835175..789c254e80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,10 +4,6 @@ on: push: tags: - 'v*' - branches: - - master - - main - - release jobs: diff --git a/Taskfile.yaml b/Taskfile.yaml index 45fa61d7c4..e866926fe2 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -13,7 +13,7 @@ tasks: label: build-{{.TASK}} vars: BUILD_VERSION: - sh: git describe --tags + sh: git describe --tags --always --match 'v*' BUILD_COMMIT: sh: git rev-parse HEAD BUILD_DATE: diff --git a/build.ps1 b/build.ps1 index aa7c3a9481..2f2335c38b 100644 --- a/build.ps1 +++ b/build.ps1 @@ -9,20 +9,20 @@ function PlatformToEnv($os, $arch) { $env:CGO_ENABLED = 0 $env:GOOS = $os $env:GOARCH = $arch - + switch -Regex ($arch) { - "arm" { + "arm" { $env:GOARM = "7" } - "armv5" { + "armv5" { $env:GOARM = "5" $env:GOARCH = "arm" } - "armv6" { + "armv6" { $env:GOARM = "6" $env:GOARCH = "arm" } - "armv7" { + "armv7" { $env:GOARM = "7" $env:GOARCH = "arm" } @@ -67,7 +67,7 @@ if ($env:HY_APP_VERSION) { $ldflags += " -X 'main.appVersion=$($env:HY_APP_VERSION)'" } else { - $ldflags += " -X 'main.appVersion=$(git describe --tags --always)'" + $ldflags += " -X 'main.appVersion=$(git describe --tags --always --match "v*")'" } if ($env:HY_APP_COMMIT) { $ldflags += " -X 'main.appCommit=$($env:HY_APP_COMMIT)'"