codacy / git-version

Git versioning used in Codacy
Apache License 2.0
135 stars 43 forks source link

[CY-6250] Version not updating #58

Open daniel-van-niekerk opened 2 years ago

daniel-van-niekerk commented 2 years ago

Version stays on 0.0.1. What am I missing?

github-actions[bot] commented 2 years ago

Internal ticket created : CY-6250

james-arawhanui commented 2 years ago

I believe the docs need to emphasize adding the tag back on the commit during the same workflow that the version is bumped.

Hopefully this helps, here are the relevant sections I found myself stuck on for a few hours today:

on:
  push:
    branches: ["main"]
    paths:
      # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-file-paths
      #
      # anything within the solution directory (recursive)
      - repo-root/path/to/module/**
      #
      # trigger when this workflow gets updated also.
      - .github/workflows/module.yml

# ...

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    permissions:
      # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
      contents: write
      packages: write

# ...

      - name: Git Version
        id: gitversion
        uses: codacy/git-version@2.5.4
        with:
          log-paths: repo-root/path/to/module
          release-branch: main

# ...

      - name: Extract metadata (tags, labels) for Docker
        # https://github.com/docker/metadata-action
        id: meta
        uses: docker/metadata-action@v4.0.1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          #
          # https://stackoverflow.com/questions/59191913/how-do-i-get-the-output-of-a-specific-step-in-github-actions
          tags: |
            type=semver,pattern={{version}},value=${{steps.gitversion.outputs.version}}

      - name: Build and push Docker image
        # https://github.com/docker/build-push-action
        uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
        with:
          context: ./repo-root/path/to/module
          file: ./repo-root/path/to/module/Dockerfile
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

      - name: Tag Release
        # https://github.com/marketplace/actions/create-update-tag
        uses: rickstaa/action-create-tag@v1
        with:
          tag: ${{ steps.gitversion.outputs.version }}
          message: "Releasing version ${{ steps.gitversion.outputs.version }}"