diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 996ab17..bc928c9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,53 +12,59 @@ jobs: docker-build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/NillionNetwork/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=tag - flavor: | - latest=false # Ensure 'latest' tag is not generated + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/NillionNetwork/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + flavor: | + latest=false # Ensure 'latest' tag is not generated - - name: Build Docker image - uses: docker/build-push-action@v2 - with: - context: . - tags: ${{ steps.meta.outputs.tags }} + - name: Set VERSION environment variable + run: | + # Extract the first tag from the generated tags + TAG=$(echo ${{ steps.meta.outputs.tags }} | cut -d ',' -f 1) + echo "VERSION=$TAG" >> $GITHUB_ENV - - name: Debug tags - run: | - echo "Generated tags: ${{ steps.meta.outputs.tags }}" - echo "Generated labels: ${{ steps.meta.outputs.labels }}" + - name: Build Docker image + uses: docker/build-push-action@v2 + with: + context: . + tags: ${{ steps.meta.outputs.tags }} - - name: List Docker images - run: docker images + - name: Debug tags + run: | + echo "Generated tags: ${{ steps.meta.outputs.tags }}" + echo "Generated labels: ${{ steps.meta.outputs.labels }}" - - name: Test nilchaind is runnable - run: | - # Extract the tag from the current context - TAG=$(echo ${{ steps.meta.outputs.tags }} | cut -d ',' -f 1) - echo "Running Docker container with tag: $TAG" - docker run --rm $TAG version + - name: List Docker images + run: docker images - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Test nilchaind is runnable + run: | + # Extract the tag from the current context + TAG=$(echo ${{ steps.meta.outputs.tags }} | cut -d ',' -f 1) + echo "Running Docker container with tag: $TAG" + docker run --rm $TAG version - - name: Push Docker image - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d5a68de..6797a26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,8 @@ ADD nilchaind nilchaind ADD params params ADD x x -ADD .git .git +ARG VERSION +ENV VERSION=${VERSION} COPY Makefile . COPY go.mod . diff --git a/Makefile b/Makefile index 67aee73..a2b66ba 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ #!/usr/bin/make -f -VERSION := $(shell echo $(shell git describe --always) | sed 's/^v//') +ifndef VERSION + VERSION := $(shell echo $(shell git describe --always) | sed 's/^v//') +endif + export TMVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') export COMMIT := $(shell git log -1 --format='%H')