Use timestamp instead of build number increase.

This commit is contained in:
SergeantPanda 2025-04-27 17:46:27 -05:00
parent 768ca0e353
commit c049e48c08
5 changed files with 15 additions and 26 deletions

View file

@ -44,28 +44,20 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Increment Build Number
if: steps.check_actor.outputs.is_bot != 'true'
id: increment_build
- name: Generate timestamp for build
id: timestamp
run: |
python scripts/increment_build.py
BUILD=$(python -c "import version; print(version.__build__)")
echo "build=${BUILD}" >> $GITHUB_OUTPUT
TIMESTAMP=$(date -u +'%Y%m%d%H%M%S')
echo "timestamp=${TIMESTAMP}" >> $GITHUB_OUTPUT
- name: Commit Build Number Update
if: steps.check_actor.outputs.is_bot != 'true'
run: |
git add version.py
git commit -m "Increment build number to ${{ steps.increment_build.outputs.build }} [skip ci]"
git push
# Update the timestamp in version.py
sed -i "s/__timestamp__ = None/__timestamp__ = '${TIMESTAMP}'/" version.py
- name: Extract version info
id: version
run: |
VERSION=$(python -c "import version; print(version.__version__)")
BUILD=$(python -c "import version; print(version.__build__)")
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "build=${BUILD}" >> $GITHUB_OUTPUT
echo "sha_short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Set repository and image metadata
@ -98,7 +90,6 @@ jobs:
echo "is_fork=true" >> $GITHUB_OUTPUT
else
echo "is_fork=false" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker image
uses: docker/build-push-action@v4
@ -108,7 +99,7 @@ jobs:
platforms: linux/amd64 # Fast build - amd64 only
tags: |
ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:${{ steps.meta.outputs.branch_tag }}
ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:${{ steps.version.outputs.version }}-${{ steps.version.outputs.build }}
ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:${{ steps.version.outputs.version }}-${{ steps.timestamp.outputs.timestamp }}
ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:${{ steps.version.outputs.sha_short }}
build-args: |
BRANCH=${{ github.ref_name }}

View file

@ -95,8 +95,8 @@ def environment(request):
@api_view(['GET'])
def version(request):
# Import version information
from version import __version__, __build__
from version import __version__, __timestamp__
return Response({
'version': __version__,
'build': __build__,
'timestamp': __timestamp__,
})

View file

@ -3,11 +3,9 @@ docker build --build-arg BRANCH=dev -t dispatcharr/dispatcharr:dev -f Dockerfile
# Get version information
VERSION=$(python -c "import sys; sys.path.append('..'); import version; print(version.__version__)")
BUILD=$(python -c "import sys; sys.path.append('..'); import version; print(version.__build__)")
# Build with version tags
# Build with version tag
docker build --build-arg BRANCH=dev \
-t dispatcharr/dispatcharr:dev \
-t dispatcharr/dispatcharr:${VERSION}-${BUILD} \
-t dispatcharr/dispatcharr:${VERSION} \
-f Dockerfile ..
.

View file

@ -67,7 +67,7 @@ const Sidebar = ({ collapsed, toggleDrawer, drawerWidth, miniDrawerWidth }) => {
const environment = useSettingsStore((s) => s.environment);
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
const publicIPRef = useRef(null);
const [appVersion, setAppVersion] = useState({ version: '', build: '' });
const [appVersion, setAppVersion] = useState({ version: '', timestamp: null });
// Fetch environment settings including version on component mount
useEffect(() => {
@ -89,7 +89,7 @@ const Sidebar = ({ collapsed, toggleDrawer, drawerWidth, miniDrawerWidth }) => {
const versionData = await API.getVersion();
setAppVersion({
version: versionData.version || '',
build: versionData.build || '',
timestamp: versionData.timestamp || null,
});
} catch (error) {
console.error('Failed to fetch version information:', error);
@ -266,7 +266,7 @@ const Sidebar = ({ collapsed, toggleDrawer, drawerWidth, miniDrawerWidth }) => {
{!collapsed && (
<Text size="xs" style={{ padding: '0 16px 16px' }} c="dimmed">
v{appVersion?.version || '0.0.0'}
{appVersion?.build !== '0' ? `-${appVersion?.build}` : ''}
{appVersion?.timestamp ? `-${appVersion.timestamp}` : ''}
</Text>
)}
</AppShell.Navbar>

View file

@ -2,4 +2,4 @@
Dispatcharr version information.
"""
__version__ = '0.3.3' # Follow semantic versioning (MAJOR.MINOR.PATCH)
__build__ = '36' # Auto-incremented on builds
__timestamp__ = None # Set during CI/CD build process