-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (81 loc) · 3.47 KB
/
maven.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
86
87
88
89
90
91
92
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Build Plugin
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "adopt"
cache: maven
- name: compile project
run: mvn --batch-mode --update-snapshots verify
- name: upload artifact
run: |
mkdir staging
cp target/paintball*.jar staging
release_file=$(ls staging)
mv staging/$release_file staging/release.jar
- uses: actions/upload-artifact@v3
with:
name: plugin
path: staging/release.jar
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: download artifact
uses: actions/download-artifact@v3
id: download
with:
name: plugin
path: ~/artifact
- name: display downloaded files
working-directory: ${{ steps.download.outputs.download-path }}
run: ls -R
- name: list used variables
run: echo "${{ github.api_url }}, ${{ github.repository }}, ${{ github.ref_name }}, ${{ github.sha }}, ${{ steps.download.outputs.download-path }}"
- name: create release and upload
run: |
latest_info=$(curl --request GET \
--url ${{ github.api_url }}/repos/${{ github.repository }}/releases/latest \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ github.token }}' \
)
tag_name=$(echo "$latest_info" | jq --raw-output '.tag_name')
tag_number=$(echo "$tag_name" | grep -Po '\d*$')
next_tag_number=$((tag_number+1))
next_tag_name=$(echo "$tag_name" | sed "s/[[:digit:]]*$/$next_tag_number/")
echo "last release tag: $tag_name next will be: $next_tag_name"
draft_info=$(curl --request POST \
--url ${{ github.api_url }}/repos/${{ github.repository }}/releases \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ github.token }}' \
--header 'Content-Type: application/json' \
--data "{
\"tag_name\": \"$next_tag_name\",
\"target_commitish\": \"${{ github.sha }}\",
\"generate_release_notes\": true,
\"name\": \"Plugin 1.19\",
\"draft\": true }" \
)
curl --request POST \
--url "$(echo "$draft_info" | jq --raw-output '.upload_url' | sed 's/{.*}$/?name=paintball-19.jar/')" \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ github.token }}' \
--header 'Content-Type: application/java-archive' \
--data-binary '@${{ steps.download.outputs.download-path }}/release.jar'
curl --request PATCH \
--url "${{ github.api_url }}/repos/${{ github.repository }}/releases/$(echo "$draft_info" | jq --raw-output '.id')" \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ github.token }}' \
--header 'Content-Type: application/json' \
--data '{
"draft": false
}'