From c049e48c0877f40fcfeb42a2ec248d50afea6179 Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Sun, 27 Apr 2025 17:46:27 -0500 Subject: [PATCH] Use timestamp instead of build number increase. --- .github/workflows/ci.yml | 23 +++++++---------------- core/api_views.py | 4 ++-- docker/build-dev.sh | 6 ++---- frontend/src/components/Sidebar.jsx | 6 +++--- version.py | 2 +- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8aa06d0d..62f01629 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/core/api_views.py b/core/api_views.py index d9c0aba4..7f3ecf57 100644 --- a/core/api_views.py +++ b/core/api_views.py @@ -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__, }) diff --git a/docker/build-dev.sh b/docker/build-dev.sh index 65d643a7..b02c314e 100755 --- a/docker/build-dev.sh +++ b/docker/build-dev.sh @@ -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 .. -. diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsx index b5dc15b2..eb5a2226 100644 --- a/frontend/src/components/Sidebar.jsx +++ b/frontend/src/components/Sidebar.jsx @@ -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 && ( v{appVersion?.version || '0.0.0'} - {appVersion?.build !== '0' ? `-${appVersion?.build}` : ''} + {appVersion?.timestamp ? `-${appVersion.timestamp}` : ''} )} diff --git a/version.py b/version.py index 4b1e4acc..9339fcbd 100644 --- a/version.py +++ b/version.py @@ -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