-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (120 loc) · 4.98 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
name: Release image
on: # yamllint disable-line rule:truthy
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
check_versions:
name: Release - Version checking
runs-on: ubuntu-latest
outputs:
base_version: ${{ steps.sogo.outputs.VERSION }}
revision: ${{ steps.image.outputs.REVISION }}
next_revision: ${{ steps.image.outputs.NEXT_REVISION }}
release: ${{ steps.condition.outputs.RELEASE }}
steps:
- name: Get latest version of SOGo
id: sogo
run: |
echo "VERSION=$(curl -s https://api.github.com/repos/Alinto/sogo/releases/latest | jq -r '.tag_name' | sed 's/SOGo-//')" >> "$GITHUB_OUTPUT"
- name: Get latest version of Docker image
id: image
run: |
RAW_LATEST_RELEASE=$(curl -s https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest)
VERSION=$(echo "$RAW_LATEST_RELEASE" | jq -r '.tag_name')
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "BASE_VERSION=$(echo "$VERSION" | sed 's/-.*//')" >> "$GITHUB_OUTPUT"
REVISION=$([[ "$VERSION" == *-* ]] && echo "$VERSION" | sed 's/.*-//' || echo "")
echo "REVISION=$REVISION" >> "$GITHUB_OUTPUT"
NEXT_REVISION=$([[ "$REVISION" =~ ^[0-9]+$ ]] && echo $(($REVISION + 1)) || echo 1)
echo "NEXT_REVISION=$NEXT_REVISION" >> "$GITHUB_OUTPUT"
- name: Decide if release version or not
id: condition
env:
SOGO_VERSION: ${{steps.sogo.outputs.VERSION}}
DOCKER_VERSION: ${{steps.image.outputs.BASE_VERSION}}
DOCKER_REVISION: ${{steps.image.outputs.REVISION}}
ACTION_TRIGGER: ${{github.event_name}}
run: |
VERSIONS_ARE_EQUAL=$([ "$SOGO_VERSION" = "$DOCKER_VERSION" ] && echo "true" || echo "false")
if [ "$ACTION_TRIGGER" = "workflow_dispatch" ] || [ "$VERSIONS_ARE_EQUAL" != "true" ]; then
RELEASE="true"
else
RELEASE="false"
fi
echo "RELEASE=$RELEASE" >> "$GITHUB_OUTPUT"
release:
name: Release - Docker image
needs: check_versions
runs-on: ubuntu-latest
if: needs.check_versions.outputs.release == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker - Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Docker - GHCR Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker - Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ needs.check_versions.outputs.base_version }}
type=raw,value=${{ needs.check_versions.outputs.base_version }}-${{ needs.check_versions.outputs.next_revision }}
flavor: latest=true
- name: Docker - Build / Push
id: docker_build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
SOGO_VERSION=${{ needs.check_versions.outputs.base_version }}
- name: Github Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.check_versions.outputs.base_version }}-${{ needs.check_versions.outputs.next_revision }}
make_latest: 'true'
generate_release_notes: true
body: |
SOGo Update: https://github.com/Alinto/sogo/releases/tag/SOGo-${{ needs.check_versions.outputs.base_version }}
- name: Update Chart AppVersion
env:
APP_VERSION: ${{needs.check_versions.outputs.base_version}}
DOCKER_REVISION: ${{needs.check_versions.outputs.next_revision}}
run: |
CHART_PATH="charts/sogo/Chart.yaml"
sed -i 's|sonroyaalmerol/docker-sogo:[^ ]*|sonroyaalmerol/docker-sogo:'"$APP_VERSION"'-'"$DOCKER_REVISION"'|g' "$CHART_PATH"
sed -i 's/^appVersion:.*$/appVersion: '"$APP_VERSION"'/' "$CHART_PATH"
- name: Commit files and push it
run: |
git add .
git commit -m "chore: bump container versions in chart"
git push
release_helm:
needs: release
uses: sonroyaalmerol/docker-sogo/.github/workflows/helm-release.yml@main