-
Notifications
You must be signed in to change notification settings - Fork 7
82 lines (71 loc) · 2.48 KB
/
main.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
name: Build and Release on Tag
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build the Docker image from'
required: true
default: 'main'
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
- name: Extract Version
id: extract_version
run: |
version=$(python3 -c "import version; print(version.__version__)")
echo "VERSION=$version" >> $GITHUB_ENV
# Set up Docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to GHCR
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push Docker image to GHCR with version tag
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.VERSION }}
ghcr.io/${{ github.repository }}:latest
# Read changelog for the current version
- name: Read Changelog
id: changelog
run: |
if [ -f changelogs/${{ env.VERSION }}.md ]; then
changelog_content=$(cat changelogs/${{ env.VERSION }}.md)
echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_ENV
echo "$changelog_content" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "CHANGELOG_CONTENT=No changelog available for this release." >> $GITHUB_ENV
fi
# # Generate auto-generated release notes
# - name: Generate Auto Release Notes
# id: release_notes
# run: |
# auto_notes=$(gh release create ${{ env.VERSION }} --generate-notes --prerelease --json body --jq .body)
# echo "AUTO_RELEASE_NOTES<<EOF" >> $GITHUB_ENV
# echo "$auto_notes" >> $GITHUB_ENV
# echo "EOF" >> $GITHUB_ENV
# Create a release on GitHub
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: |
${{ env.CHANGELOG_CONTENT }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}