-
-
Notifications
You must be signed in to change notification settings - Fork 167
125 lines (106 loc) · 4.07 KB
/
version-and-release.yml
File metadata and controls
125 lines (106 loc) · 4.07 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
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
name: Create Release and Build Docker Images
on:
pull_request:
types: [closed]
branches:
- main
jobs:
create-release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Determine new version
id: version
run: |
CURRENT_VERSION="0.4.1"
# Check commit messages to determine version increment
COMMITS=$(git log $(git describe --tags --abbrev=0 2>/dev/null || echo HEAD~10)..HEAD --pretty=format:"%s")
MAJOR_CHANGE=false
MINOR_CHANGE=false
PATCH_CHANGE=true # Default to patch if no specific keywords found
echo "$COMMITS" | while read -r commit; do
if [[ "$commit" == *"BREAKING CHANGE"* || "$commit" == *"!:"* ]]; then
MAJOR_CHANGE=true
break
elif echo "$commit" | grep -Eq "^feat(\([^)]+\))?:.*"; then
MINOR_CHANGE=true
fi
done
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
if [ "$MAJOR_CHANGE" = true ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "$MINOR_CHANGE" = true ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "New version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "release_tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.release_tag }}
release_name: Release ${{ steps.version.outputs.release_tag }}
draft: false
prerelease: false
body: |
Release ${{ steps.version.outputs.release_tag }}
Changes in this release:
${{ github.event.pull_request.title }} (#${{ github.event.pull_request.number }})
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push CPU Docker image
- name: Build and push CPU Docker image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
file: ./Dockerfile
tags: |
ghcr.io/rishikanthc/scriberr:${{ steps.version.outputs.new_version }}
ghcr.io/rishikanthc/scriberr:latest
# Build and push CUDA Docker image
- name: Build and push CUDA Docker image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
file: ./Dockerfile-cuda128
tags: |
ghcr.io/rishikanthc/scriberr:${{ steps.version.outputs.new_version }}-cuda128
ghcr.io/rishikanthc/scriberr:latest-cuda128
- name: Verify multi-platform images
run: |
docker buildx imagetools inspect ghcr.io/rishikanthc/scriberr:${{ steps.version.outputs.new_version }}
docker buildx imagetools inspect ghcr.io/rishikanthc/scriberr:latest
docker buildx imagetools inspect ghcr.io/rishikanthc/scriberr:${{ steps.version.outputs.new_version }}-cuda128
docker buildx imagetools inspect ghcr.io/rishikanthc/scriberr:latest-cuda128