Skip to content

Commit

Permalink
Add versioning to Docker workflow and create VERSION file
Browse files Browse the repository at this point in the history
  • Loading branch information
athrvk committed Dec 7, 2024
1 parent 9ec0f4d commit cc9045b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
45 changes: 27 additions & 18 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,37 @@ jobs:
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: calibre-puppeteer-base
- name: Read the current version
id: get_version
run: echo "::set-output name=version::$(cat VERSION)"

- name: Increment the version
id: increment_version
run: |
current_version=$(cat VERSION)
IFS='.' read -r -a version_parts <<< "$current_version"
version_parts[2]=$((version_parts[2] + 1))
new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
echo $new_version > VERSION
echo "::set-output name=new_version::$new_version"
- name: Commit the new version
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add VERSION
git commit -m "Increment version to ${{ steps.increment_version.outputs.new_version }}"
git push
- name: Build the Docker image
run: docker build . --file Dockerfile --tag calibre-puppeteer-base:${{ steps.meta.outputs.tags }}
run: docker build . --file Dockerfile --tag calibre-puppeteer-base:${{ steps.increment_version.outputs.new_version }}

- name: Verification step
run: |
# Run Calibre version command to verify installation
docker run --rm calibre-puppeteer-base:${{ steps.meta.outputs.tags }} ebook-convert --version
docker run --rm calibre-puppeteer-base:${{ steps.increment_version.outputs.new_version }} ebook-convert --version
# Run Puppeteer to verify installation
docker run --rm --security-opt seccomp=chrome.json calibre-puppeteer-base:${{ steps.meta.outputs.tags }} node -e "const browser = require('puppeteer').launch(); console.log('Puppeteer works')"
- name: Build and push Docker image
if: success() # Ensures this step runs only if the previous steps are successful
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
docker run --rm --security-opt seccomp=chrome.json calibre-puppeteer-base:${{ steps.increment_version.outputs.new_version }} node -e "const browser = require('puppeteer').launch(); console.log('Puppeteer works')"
- name: Push Docker image
run: docker push calibre-puppeteer-base:${{ steps.increment_version.outputs.new_version }}
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0

0 comments on commit cc9045b

Please sign in to comment.