diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4e764d0..6d8ee51 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -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 'github-actions@github.com' + 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 }} diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..afaf360 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file