From 756654de7d1dd064861de1dc40922d393848b6f6 Mon Sep 17 00:00:00 2001 From: Sumedh K Date: Mon, 16 Mar 2026 21:30:32 -0400 Subject: [PATCH] github actions auto release --- .github/workflows/build_and_test.yml | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index e5cab89..63eae70 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -16,7 +16,7 @@ jobs: - name: Push image to Docker Hub run: | - docker login -u kkittur -p ${{ secrets.DOCKER_HUB_TOKEN }} + echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u kkittur --password-stdin docker push kkittur/drivebrain_cross_compile:latest build-executable: @@ -27,23 +27,17 @@ jobs: uses: actions/checkout@v4 - name: Pull from container registry - run: | - docker pull kkittur/drivebrain_cross_compile:latest + run: docker pull kkittur/drivebrain_cross_compile:latest - name: Enter container and build - run: | - docker compose run --rm dev ./build_script.sh - - - name: Extract binary from build - run: | - docker compose run --rm dev cp build-arm/drivebrain /app/drivebrain-arm + run: docker compose run --rm dev ./build_script.sh - name: Upload build artifact if: github.ref == 'refs/heads/main' uses: actions/upload-artifact@v4 with: name: drivebrain-arm-binary - path: drivebrain-arm + path: build-arm/drivebrain create-release: needs: [publish-image, build-executable] @@ -56,18 +50,24 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-tags: true - name: Determine next version id: version run: | - git fetch --tags - LATEST=$(git tag -l 'v[0-9]*' | sort -t'v' -k2 -n | tail -1) + git fetch --tags --force + LATEST=$(git tag -l 'v*' | grep -E '^v[0-9]+$' | sort -V | tail -1) if [ -z "$LATEST" ]; then NEXT="v1" else - NUM=${LATEST#v} + NUM="${LATEST#v}" NEXT="v$((NUM + 1))" fi + if [ -z "$NEXT" ] || ! echo "$NEXT" | grep -qE '^v[0-9]+$'; then + echo "ERROR: computed tag '$NEXT' is invalid" + exit 1 + fi + echo "Computed next version: $NEXT" echo "tag=$NEXT" >> "$GITHUB_OUTPUT" - name: Download build artifact @@ -79,14 +79,14 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - gh release create ${{ steps.version.outputs.tag }} \ + gh release create "${{ steps.version.outputs.tag }}" \ --title "Release ${{ steps.version.outputs.tag }}" \ --generate-notes \ - drivebrain-arm + drivebrain - name: Tag and push versioned Docker image run: | - docker login -u kkittur -p ${{ secrets.DOCKER_HUB_TOKEN }} + echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u kkittur --password-stdin docker pull kkittur/drivebrain_cross_compile:latest - docker tag kkittur/drivebrain_cross_compile:latest kkittur/drivebrain_cross_compile:${{ steps.version.outputs.tag }} - docker push kkittur/drivebrain_cross_compile:${{ steps.version.outputs.tag }} + docker tag kkittur/drivebrain_cross_compile:latest "kkittur/drivebrain_cross_compile:${{ steps.version.outputs.tag }}" + docker push "kkittur/drivebrain_cross_compile:${{ steps.version.outputs.tag }}"