|
@@ -1,8 +1,12 @@
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
name: Release Docker Image
|
|
name: Release Docker Image
|
|
|
|
|
|
|
|
on:
|
|
on:
|
|
|
release:
|
|
release:
|
|
|
types: [published]
|
|
types: [published]
|
|
|
|
|
+ workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
jobs:
|
|
|
build-and-push:
|
|
build-and-push:
|
|
@@ -10,6 +14,23 @@ jobs:
|
|
|
steps:
|
|
steps:
|
|
|
- name: Checkout code
|
|
- name: Checkout code
|
|
|
uses: actions/checkout@v4
|
|
uses: actions/checkout@v4
|
|
|
|
|
+ with:
|
|
|
|
|
+ fetch-depth: 0 # Fetch all history and tags
|
|
|
|
|
+
|
|
|
|
|
+ - name: Extract tag (manual)
|
|
|
|
|
+ if: github.event_name == 'workflow_dispatch'
|
|
|
|
|
+ id: set_tag_manual
|
|
|
|
|
+ run: |
|
|
|
|
|
+ # Checkout the latest tag and set output
|
|
|
|
|
+ git fetch --tags
|
|
|
|
|
+ LATEST_TAG=$(git describe --tags --abbrev=0)
|
|
|
|
|
+ git checkout $LATEST_TAG
|
|
|
|
|
+ echo "tag=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
|
|
|
|
|
+
|
|
|
|
|
+ - name: Extract tag (release)
|
|
|
|
|
+ if: github.event_name == 'release'
|
|
|
|
|
+ id: set_tag_release
|
|
|
|
|
+ run: echo "tag=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
- name: Set up Docker Buildx
|
|
|
uses: docker/setup-buildx-action@v3
|
|
uses: docker/setup-buildx-action@v3
|
|
@@ -20,16 +41,13 @@ jobs:
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- - name: Extract version tag without 'v'
|
|
|
|
|
- id: set_tag
|
|
|
|
|
- run: echo "tag=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
|
|
|
|
|
-
|
|
|
|
|
- name: Build and push Docker image
|
|
- name: Build and push Docker image
|
|
|
uses: docker/build-push-action@v5
|
|
uses: docker/build-push-action@v5
|
|
|
with:
|
|
with:
|
|
|
context: .
|
|
context: .
|
|
|
file: ./Dockerfile
|
|
file: ./Dockerfile
|
|
|
push: true
|
|
push: true
|
|
|
|
|
+ # Use extracted tag without leading 'v'
|
|
|
tags: |
|
|
tags: |
|
|
|
yhirose4dockerhub/cpp-httplib-server:latest
|
|
yhirose4dockerhub/cpp-httplib-server:latest
|
|
|
- yhirose4dockerhub/cpp-httplib-server:${{ steps.set_tag.outputs.tag }}
|
|
|
|
|
|
|
+ yhirose4dockerhub/cpp-httplib-server:${{ steps.set_tag_manual.outputs.tag || steps.set_tag_release.outputs.tag }}
|