NLnetLabs / ploutos

Reusable packaging workflow for Rust projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version number determination should be more robust

ximon18 opened this issue · comments

Currently O/S packaging takes the version number to use from Cargo.toml while Docker packaging determines the version number based on the current Git branch or tag name. This is inconsistent and could lead to a Docker image being published with a version number in the tag that differs to the version number in the Cargo.toml.

Additionally, the version tag determination for Docker images makes assumptions about the primary Git branch being called main.

Also the Docker tag generation rules have what looks like a possible mistake:

- name: Apply rules to Git metadata to generate potential Docker tags
  id: meta
  uses: docker/metadata-action@v4
  with:
    images: ${{ inputs.docker_repo }}
    flavor: |
      latest=false
    tags: |
      type=semver,pattern={{version}},prefix=v
      type=raw,value=unstable,enable=${{ github.ref == 'refs/heads/main' }}
      type=raw,value=latest,enable=${{ github.ref != 'refs/heads/main' && !contains(github.ref, '-') }}
      type=raw,value=test,enable=${{ !contains(github.ref, 'refs/tags/v') && github.ref != 'refs/heads/main' }}

This bit looks suspect:

      type=raw,value=latest,enable=${{ github.ref != 'refs/heads/main' && !contains(github.ref, '-') }}

Shouldn't that be:

      type=raw,value=latest,enable=${{ contains(github.ref, 'refs/tags/v' && !contains(github.ref, '-') }}

?