-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (58 loc) · 1.9 KB
/
deploy.yml
File metadata and controls
66 lines (58 loc) · 1.9 KB
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
name: Build and Deploy
on:
push:
branches: [main]
workflow_dispatch:
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Calculate next version
id: version
run: |
LATEST_TAG=$(git tag -l "v*" | sort -V | tail -1)
if [ -z "$LATEST_TAG" ]; then
NEXT_VERSION="v0.1.0"
else
VERSION_WITHOUT_V=${LATEST_TAG#v}
IFS='.' read -ra VERSION_PARTS <<< "$VERSION_WITHOUT_V"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
PATCH=$((PATCH + 1))
NEXT_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
fi
echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "Next version: $NEXT_VERSION"
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.version.outputs.version }} \
--title "Release ${{ steps.version.outputs.version }}" \
--generate-notes \
--target main
build-and-push:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ vars.REGISTRY_HOST }}" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ vars.REGISTRY_HOST }}/silverback:${{ needs.create-release.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max