-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add versioning to Docker workflow and create VERSION file
- Loading branch information
Showing
2 changed files
with
28 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |