-
Notifications
You must be signed in to change notification settings - Fork 57
85 lines (74 loc) · 2.51 KB
/
create_release.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
83
84
85
name: Create release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Setup Java SDK
uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: 17
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Check commit title and extract version
run: |
export commit_title=$(git log --pretty=format:%s -1 ${{ github.ref }})
echo "Commit title: $commit_title"
if [[ $commit_title =~ ^Release\ version\ [0-9]*\.[0-9]*\.[0-9]*$ ]]; then
echo "Valid commit title"
else
echo "Invalid commit title"
exit 1
fi
export version=$(echo ${commit_title} | sed s/^Release\ version\ //g)
echo "Will use version ${version}"
echo "version=${version}" >> $GITHUB_ENV
- name: Build
run: |
./gradlew distTar distZip
export tar_file=$(ls ./build/distributions/ | grep tar)
export zip_file=$(ls ./build/distributions/ | grep zip)
echo tar_file=${tar_file} >> $GITHUB_ENV
echo zip_file=${zip_file} >> $GITHUB_ENV
echo tar_path=`realpath ./build/distributions/${tar_file}` >> $GITHUB_ENV
echo zip_path=`realpath ./build/distributions/${zip_file}` >> $GITHUB_ENV
- name: Create release draft
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.version }}"
release_name: "v${{ env.version }}"
commitish: ${{ github.sha }}
body: |
*Fill in*
draft: true
prerelease: false
- name: Upload tar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.tar_path }}
asset_name: ${{ env.tar_file }}
asset_content_type: application/tar
- name: Upload zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.zip_path }}
asset_name: ${{ env.zip_file }}
asset_content_type: application/zip