diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 6e0cb48..c431797 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -21,9 +21,7 @@ jobs: - name: Set build number id: set-build-number run: | - new_version=$(bash ${GITHUB_WORKSPACE}/Utility/set_buildnumber.sh ${{ vars.BUILD_NUMBER }}) - echo "new_version=${new_version}" >> $GITHUB_ENV - echo "new_version=${new_version}" >> $GITHUB_OUTPUT + bash ${GITHUB_WORKSPACE}/Utility/set_buildnumber.sh ${{ vars.BUILD_NUMBER }} - name: Update repo variable run: | @@ -81,5 +79,5 @@ jobs: no-cache: true platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 tags: | - mgoerentz/threadfin:${{ env.NEW_VERSION }}-beta mgoerentz/threadfin:latest-beta + mgoerentz/threadfin:v${{ env.NEW_VERSION }}-beta diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a59250..202b39b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,8 @@ name: Threadfin Build on: push: - tags: - - 'v*' + branches: + - master permissions: contents: write @@ -10,6 +10,8 @@ jobs: buildBinaries: name: Build and release binaries runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.set-build-number.outputs.new_version }} steps: - name: Check out code into the Go module directory uses: actions/checkout@v4 @@ -17,12 +19,13 @@ jobs: ref: main - name: Set build number + id: set-build-number run: | - bash ${GITHUB_WORKSPACE}/Utility/set_buildnumber.sh ${{ vars.BUILD_NUMBER }} + bash ${GITHUB_WORKSPACE}/Utility/set_build_number.sh ${{ vars.BUILD_NUMBER }} - name: Update repo variable run: | - bash ${GITHUB_WORKSPACE}/Utility/update_buildnumber_variable.sh ${{ secrets.API_TOKEN }} ${{ github.repository }} ${{ env.NEW_BUILD }} + bash ${GITHUB_WORKSPACE}/Utility/update_build_number_variable.sh ${{ secrets.API_TOKEN }} ${{ github.repository }} ${{ env.NEW_BUILD }} - name: Set up and Build uses: actions/setup-go@v5 @@ -45,10 +48,15 @@ jobs: buildDockerImages: name: Build and push Docker Images runs-on: ubuntu-latest + needs: buildBinaries steps: - name: Checkout uses: actions/checkout@v4 + - name: Set NEW_VERSION + run: echo "NEW_VERSION=${{ needs.buildBinaries.outputs.new_version }}" >> $GITHUB_ENV + shell: bash + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -69,4 +77,4 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 tags: | mgoerentz/threadfin:latest - mgoerentz/threadfin:${{ github.ref_name }} + mgoerentz/threadfin:v${{ env.NEW_VERSION }} diff --git a/Utility/set_buildnumber.sh b/Utility/set_build_number.sh similarity index 88% rename from Utility/set_buildnumber.sh rename to Utility/set_build_number.sh index 57a5d79..f56276f 100644 --- a/Utility/set_buildnumber.sh +++ b/Utility/set_build_number.sh @@ -7,8 +7,6 @@ fi new_build=$(($1 + 1)) -echo "New build number is: $new_build" - # Extract the version number version=$(grep 'const Version' "threadfin.go" | sed 's/.*Version = "\(.*\)"/\1/') @@ -21,8 +19,6 @@ minor=${version_parts[1]} patch=${version_parts[2]} new_version="$major.$minor.$patch.$new_build" -echo "New version is: $new_version" - # Update the version in the file sed -i "s/const Version = \".*\"/const Version = \"$new_version\"/" threadfin.go @@ -32,4 +28,5 @@ echo "NEW_BUILD=$new_build" >> $GITHUB_ENV # Export the new Version to the GitHub environment echo "NEW_VERSION=$new_version" >> $GITHUB_ENV -echo "$new_version" +# Set the output for the GitHub Actions step +echo "new_version=$new_version" >> $GITHUB_OUTPUT diff --git a/Utility/update_buildnumber_variable.sh b/Utility/update_build_number_variable.sh similarity index 100% rename from Utility/update_buildnumber_variable.sh rename to Utility/update_build_number_variable.sh