-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (64 loc) · 2.11 KB
/
Copy pathrelease.yml
File metadata and controls
79 lines (64 loc) · 2.11 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
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Release and Publish
on:
push:
branches:
- feat-docker
# paths:
# - Cargo.toml
permissions:
contents: write
jobs:
tag_and_release:
name: Tag and Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version_and_release.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --tags
- name: Extract version, tag, and release
id: version_and_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(grep -m1 '^version\s*=\s*"' Cargo.toml | sed 's/^[^\"]*\"\([^\"]*\)\"/\1/')
if [ -z "$VERSION" ]; then
echo "Failed to obtain version from Cargo.toml" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if git rev-parse -q --verify "refs/tags/v$VERSION" >/dev/null; then
echo "Tag v$VERSION already exists; skipping creation." >&2
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
gh release create "v$VERSION" --generate-notes
publish_docker:
name: Publish Docker Image
runs-on: ubuntu-latest
needs: tag_and_release
env:
DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/fotobot
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.DOCKER_IMAGE }}:${{ needs.tag_and_release.outputs.version }}
${{ env.DOCKER_IMAGE }}:latest