-
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (108 loc) · 3.71 KB
/
release.yml
File metadata and controls
126 lines (108 loc) · 3.71 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
test:
uses: ./.github/workflows/test-ruby.yml
permissions:
contents: read
version:
name: Calculate Version
runs-on: ubuntu-latest
needs: [test]
outputs:
current: ${{ steps.current.outputs.version }}
new: ${{ steps.new.outputs.version }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Get current version
id: current
run: |
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
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"
docker:
name: Build and Push Docker
needs: version
uses: ./.github/workflows/docker-build.yml
with:
push: true
version: ${{ needs.version.outputs.new }}
secrets:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
permissions:
contents: read
packages: write
attestations: write
id-token: write
release:
name: Create Release
needs: [version, docker]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create and push tag
run: |
git tag -a "v${{ needs.version.outputs.new }}" -m "Release version ${{ needs.version.outputs.new }}"
git push origin "v${{ needs.version.outputs.new }}"
- name: Create release archive
run: |
git archive --format=zip --prefix=play-test-v${{ needs.version.outputs.new }}/ HEAD > play-test-v${{ needs.version.outputs.new }}.zip
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.version.outputs.new }}
name: Release ${{ needs.version.outputs.new }}
body: |
# v${{ needs.version.outputs.new }}
[Read the full changelog here](https://github.com/${{ github.repository }}/compare/v${{ needs.version.outputs.current }}...v${{ needs.version.outputs.new }})
## Docker Images
- `${{ vars.DOCKER_USERNAME }}/play-test:v${{ needs.version.outputs.new }}`
- `git.chobble.com/chobble/play-test:v${{ needs.version.outputs.new }}`
- `ghcr.io/${{ github.repository }}:v${{ needs.version.outputs.new }}`
files: |
play-test-v${{ needs.version.outputs.new }}.zip
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}