fix: Fix tags in official Docker images and binaries (#1370)
The release workflows did not run checkout with `fetch-tags: true`, so the builds were unable to compute the correct release version number. I audited all instances of `actions/checkout` to add `fetch-tags` where needed and clean up unneeded options. I also had to fix options to `docker/build-push-action`, which by default ignores `actions/checkout` and tries to pull from git itself. This led to the Docker build running in a context without the new tag. Finally, to make verification easier and provide version info in the build logs, this adds debugging info to the version-generation script via stderr. Closes #1366
This commit is contained in:
parent
5ee2b7f0de
commit
d83c7b1d45
|
@ -96,6 +96,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
ref: ${{ inputs.ref }}
|
ref: ${{ inputs.ref }}
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Install Linux deps
|
- name: Install Linux deps
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
|
|
|
@ -47,6 +47,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
ref: ${{ inputs.tag }}
|
ref: ${{ inputs.tag }}
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
@ -57,6 +58,11 @@ jobs:
|
||||||
- name: Push to Docker Hub
|
- name: Push to Docker Hub
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
|
# Important: use actions/checkout source, which has the right tags!
|
||||||
|
# Without context: ., this action will try to fetch git source
|
||||||
|
# itself, and it will be unable to determine the correct version
|
||||||
|
# number.
|
||||||
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:${{ inputs.tag }}
|
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:${{ inputs.tag }}
|
||||||
|
|
||||||
|
@ -64,5 +70,10 @@ jobs:
|
||||||
if: ${{ inputs.latest }}
|
if: ${{ inputs.latest }}
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
|
# Important: use actions/checkout source, which has the right tags!
|
||||||
|
# Without context: ., this action will try to fetch git source
|
||||||
|
# itself, and it will be unable to determine the correct version
|
||||||
|
# number.
|
||||||
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:latest
|
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:latest
|
||||||
|
|
|
@ -55,7 +55,6 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Compute latest
|
- name: Compute latest
|
||||||
id: compute
|
id: compute
|
||||||
|
|
|
@ -8,23 +8,37 @@
|
||||||
"""This script is used to generate version string for packager."""
|
"""This script is used to generate version string for packager."""
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
version_tag = subprocess.check_output('git tag --points-at HEAD',
|
version_tag = subprocess.check_output('git tag --points-at HEAD',
|
||||||
stderr=subprocess.STDOUT, shell=True).decode().rstrip()
|
stderr=subprocess.STDOUT, shell=True).decode().rstrip()
|
||||||
|
if version_tag:
|
||||||
|
print('Found version tag: {}'.format(version_tag), file=sys.stderr)
|
||||||
|
else:
|
||||||
|
print('Cannot find version tag!', file=sys.stderr)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
# git tag --points-at is not supported in old versions of git. Just ignore
|
# git tag --points-at is not supported in old versions of git. Just ignore
|
||||||
# version_tag in this case.
|
# version_tag in this case.
|
||||||
version_tag = None
|
version_tag = None
|
||||||
|
print('Old version of git, cannot determine version tag!', file=sys.stderr)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
version_hash = subprocess.check_output('git rev-parse --short HEAD',
|
version_hash = subprocess.check_output('git rev-parse --short HEAD',
|
||||||
stderr=subprocess.STDOUT, shell=True).decode().rstrip()
|
stderr=subprocess.STDOUT, shell=True).decode().rstrip()
|
||||||
|
print('Version hash: {}'.format(version_hash), file=sys.stderr)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
version_hash = 'unknown-version'
|
version_hash = 'unknown-version'
|
||||||
|
print('Cannot find version hasah!', file=sys.stderr)
|
||||||
|
|
||||||
if version_tag:
|
if version_tag:
|
||||||
print('{0}-{1}'.format(version_tag, version_hash))
|
output = '{0}-{1}'.format(version_tag, version_hash)
|
||||||
else:
|
else:
|
||||||
print(version_hash)
|
output = version_hash
|
||||||
|
|
||||||
|
# Final debug message, mirroring what is used to generate the source file:
|
||||||
|
print('Final output: {}'.format(output), file=sys.stderr)
|
||||||
|
|
||||||
|
# Actually used to generate the source file:
|
||||||
|
print(output)
|
||||||
|
|
Loading…
Reference in New Issue