-
-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (133 loc) · 4.94 KB
/
Copy pathrelease.yml
File metadata and controls
156 lines (133 loc) · 4.94 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
test:
uses: ./.github/workflows/ci.yml
permissions:
contents: read
lint:
uses: ./.github/workflows/standard.yml
permissions:
checks: write
contents: write
release:
needs: [test, lint]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
attestations: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Get current version
id: current
run: |
# Get the latest tag, fallback to 0.0.0 if no tags exist
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Remove 'v' prefix if present
CURRENT_VERSION=${CURRENT_VERSION#v}
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Calculate new version
id: new
run: |
CURRENT="${{ steps.current.outputs.version }}"
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
case "${{ inputs.version }}" in
major)
NEW_VERSION="$((MAJOR + 1)).0.0"
;;
minor)
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
;;
patch)
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
;;
esac
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Create and push tag
run: |
git tag -a "v${{ steps.new.outputs.version }}" -m "Release version ${{ steps.new.outputs.version }}"
git push origin "v${{ steps.new.outputs.version }}"
- name: Create release archive
run: |
# Create a clean archive without .git directory
git archive --format=zip --prefix=pat-logger-v${{ steps.new.outputs.version }}/ HEAD > pat-logger-v${{ steps.new.outputs.version }}.zip
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Forgejo Registry
uses: docker/login-action@v3
with:
registry: git.chobble.com
username: stefan
password: ${{ secrets.FORGEJO_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ vars.DOCKER_USERNAME }}/play-test:latest
${{ vars.DOCKER_USERNAME }}/play-test:v${{ steps.new.outputs.version }}
git.chobble.com/chobble/play-test:latest
git.chobble.com/chobble/play-test:v${{ steps.new.outputs.version }}
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:v${{ steps.new.outputs.version }}
cache-from: |
type=gha
type=registry,ref=${{ vars.DOCKER_USERNAME }}/play-test:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=${{ vars.DOCKER_USERNAME }}/play-test:buildcache,mode=max
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.new.outputs.version }}
name: Release ${{ steps.new.outputs.version }}
body: |
# v${{ steps.new.outputs.version }}
[Read the full changelog here](https://github.com/${{ github.repository }}/compare/v${{ steps.current.outputs.version }}...v${{ steps.new.outputs.version }})
## Docker Images
- `${{ vars.DOCKER_USERNAME }}/play-test:v${{ steps.new.outputs.version }}`
- `git.chobble.com/chobble/play-test:v${{ steps.new.outputs.version }}`
- `ghcr.io/${{ github.repository }}:v${{ steps.new.outputs.version }}`
files: |
play-test-v${{ steps.new.outputs.version }}.zip
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}