Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix tags in official Docker images and binaries #1370

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ jobs:
with:
ref: ${{ inputs.ref }}
submodules: recursive
fetch-tags: true

- name: Install Linux deps
if: runner.os == 'Linux'
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
with:
ref: ${{ inputs.tag }}
submodules: recursive
fetch-tags: true

- name: Log in to Docker Hub
uses: docker/login-action@v3
Expand All @@ -57,12 +58,22 @@ jobs:
- name: Push to Docker Hub
uses: docker/build-push-action@v5
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
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:${{ inputs.tag }}

- name: Push to Docker Hub as "latest"
if: ${{ inputs.latest }}
uses: docker/build-push-action@v5
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
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:latest
1 change: 0 additions & 1 deletion .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-tags: true
persist-credentials: false

- name: Compute latest
id: compute
Expand Down
18 changes: 16 additions & 2 deletions packager/version/generate_version_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,37 @@
"""This script is used to generate version string for packager."""

import subprocess
import sys

if __name__ == '__main__':
try:
version_tag = subprocess.check_output('git tag --points-at HEAD',
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:
# git tag --points-at is not supported in old versions of git. Just ignore
# version_tag in this case.
version_tag = None
print('Old version of git, cannot determine version tag!', file=sys.stderr)

try:
version_hash = subprocess.check_output('git rev-parse --short HEAD',
stderr=subprocess.STDOUT, shell=True).decode().rstrip()
print('Version hash: {}'.format(version_hash), file=sys.stderr)
except subprocess.CalledProcessError as e:
version_hash = 'unknown-version'
print('Cannot find version hasah!', file=sys.stderr)

if version_tag:
print('{0}-{1}'.format(version_tag, version_hash))
output = '{0}-{1}'.format(version_tag, version_hash)
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