From eaa363eb8297d94cb7bd7092de1235b397519ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Sat, 21 Sep 2024 22:59:56 +0200 Subject: [PATCH] ci: allow to force ci build this should not build release if pipeline triggered on master and master also has a version tag. avoid building same version twice and uploading to ci and release repos. --- .github/workflows/ci.yml | 18 +++++++++++++++++- Makefile | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb93d35e..55558444 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,9 +154,15 @@ jobs: with: go-version: ${{ steps.goversion.outputs.GOVER }} + - name: "Ensure CI build" + if: github.ref == 'refs/heads/master' + run: | + echo "FORCE_CI=true" >> $GITHUB_OUTPUT + id: force_ci + - name: "Build Debian packages" env: - GOBIN: /usr/local/bin + FORCE_CI: ${{ steps.force_ci.outputs.FORCE_CI }} run: | make dpkg DEBARCH=${{ matrix.arch }} @@ -169,6 +175,7 @@ jobs: if [ -n "$APTLY_USER" ] && [ -n "$APTLY_PASSWORD" ]; then found=yes fi + echo "Aptly credentials available: $found" echo "FOUND=$found" >> $GITHUB_OUTPUT id: aptlycreds @@ -218,7 +225,15 @@ jobs: with: go-version: ${{ steps.goversion.outputs.GOVER }} + - name: "Ensure CI build" + if: github.ref == 'refs/heads/master' + run: | + echo "FORCE_CI=true" >> $GITHUB_OUTPUT + id: force_ci + - name: "Get aptly version" + env: + FORCE_CI: ${{ steps.force_ci.outputs.FORCE_CI }} run: | aptlyver=$(make -s version) echo "Aptly Version: $aptlyver" @@ -228,6 +243,7 @@ jobs: - name: "Build aptly ${{ matrix.goos }}/${{ matrix.goarch }}" env: GOBIN: /usr/local/bin + FORCE_CI: ${{ steps.force_ci.outputs.FORCE_CI }} run: | make binaries GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} diff --git a/Makefile b/Makefile index 9688ebff..9d6565ca 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ man: ## Create man pages version: ## Print aptly version @ci="" ; \ - if [ -z "`git tag --points-at HEAD`" ]; then \ + if [ "`make -s releasetype`" = "ci" ]; then \ ci=`TZ=UTC git show -s --format='+%cd.%h' --date=format-local:'%Y%m%d%H%M%S'`; \ fi ; \ if which dpkg-parsechangelog > /dev/null 2>&1; then \ @@ -103,7 +103,7 @@ version: ## Print aptly version releasetype: # Print release type (ci/release) @reltype=ci ; \ gitbranch=`git rev-parse --abbrev-ref HEAD` ; \ - if [ "$$gitbranch" = "HEAD" ]; then \ + if [ "$$gitbranch" = "HEAD" ] && [ "$$FORCE_CI" != "true" ]; then \ gittag=`git describe --tags --exact-match` ;\ if echo "$$gittag" | grep -q '^v[0-9]'; then \ reltype=release ; \