|
1 |
| -name: Docker Publish and Versioning |
| 1 | +name: Docker Latest Version |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - "master"
|
7 |
| - tags: |
8 |
| - - 'v*.*.*' |
9 | 7 | pull_request:
|
10 | 8 | branches:
|
11 | 9 | - "master"
|
12 | 10 | workflow_dispatch:
|
13 |
| - |
14 |
| -env: |
15 |
| - # Docker Hub registry URL (use docker.io for Docker Hub) |
16 |
| - REGISTRY: docker.io |
17 |
| - IMAGE_NAME: ${{ github.repository }} |
18 |
| - |
19 | 11 | jobs:
|
20 | 12 | build:
|
21 | 13 | runs-on: ubuntu-latest
|
|
27 | 19 | - name: Checkout repository
|
28 | 20 | uses: actions/checkout@v4
|
29 | 21 |
|
30 |
| - - name: Set up Git versioning |
31 |
| - id: version |
32 |
| - run: | |
33 |
| - # Set version based on commit message prefix (fix, feat, chore or improvement) |
34 |
| - latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") |
35 |
| - commit_message=$(git log -1 --pretty=%B) |
36 |
| - version_prefix=${latest_tag#v} |
37 |
| - major=$(echo $version_prefix | cut -d'.' -f1) |
38 |
| - minor=$(echo $version_prefix | cut -d'.' -f2) |
39 |
| - patch=$(echo $version_prefix | cut -d'.' -f3) |
40 |
| -
|
41 |
| - if [[ "$commit_message" =~ ^feat\(.*\) ]]; then |
42 |
| - # Bump major version, reset minor and patch |
43 |
| - major=$((major + 1)) |
44 |
| - minor=0 |
45 |
| - patch=0 |
46 |
| - elif [[ "$commit_message" =~ ^fix\(.*\) ]]; then |
47 |
| - # Bump patch version |
48 |
| - patch=$((patch + 1)) |
49 |
| - elif [[ "$commit_message" =~ ^chore\(.*\) || "$commit_message" =~ ^improvement\(.*\) ]]; then |
50 |
| - # Bump minor version, reset patch |
51 |
| - minor=$((minor + 1)) |
52 |
| - patch=0 |
53 |
| - fi |
54 |
| -
|
55 |
| - new_version="v$major.$minor.$patch" |
56 |
| - echo "new_version=$new_version" >> $GITHUB_ENV |
57 |
| - echo "New Version: $new_version" |
58 |
| -
|
59 | 22 | # Install cosign tool, only run if it's not a pull request
|
60 | 23 | - name: Install cosign
|
61 | 24 | if: github.event_name != 'pull_request'
|
|
81 | 44 |
|
82 | 45 | with:
|
83 | 46 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
84 |
| - tags: | |
85 |
| - ${{ env.new_version }} |
86 |
| - latest |
| 47 | + tags: latest |
87 | 48 |
|
88 | 49 | # Build and push Docker image, skip pushing on PRs
|
89 | 50 | - name: Build and push Docker image
|
|
92 | 53 | with:
|
93 | 54 | context: .
|
94 | 55 | push: ${{ github.event_name != 'pull_request' }}
|
95 |
| - tags: | |
96 |
| - ${{ steps.meta.outputs.tags }} |
97 |
| - latest |
| 56 | + tags: latest |
98 | 57 | labels: ${{ steps.meta.outputs.labels }}
|
99 | 58 | cache-from: type=gha
|
100 | 59 | cache-to: type=gha,mode=max
|
101 |
| - |
102 |
| - # Sign the resulting Docker image digest except on PRs |
103 |
| -# - name: Sign the published Docker image |
104 |
| -# if: ${{ github.event_name != 'pull_request' }} |
105 |
| -# env: |
106 |
| -# TAGS: ${{ steps.meta.outputs.tags }} |
107 |
| -# DIGEST: ${{ steps.build-and-push.outputs.digest }} |
108 |
| -# run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} |
0 commit comments