-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (79 loc) · 2.85 KB
/
main.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
# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
# - Remove Old Draft Releases
# - Create New Draft Release
# The workflow is triggered on push to the main branch
#
# GitHub Actions reference: https://help.github.com/en/actions
#
on:
push:
branches:
- main
jobs:
publish_snapshot:
name: Publish Snapshot
runs-on: ubuntu-latest
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
- name: Update Version Name
run: |
file="gradle.properties"
# Check if the file exists
if [ ! -f "$file" ]; then
echo "$file does not exist."
exit 1
fi
# Append -SNAPSHOT to the VERSION_NAME
sed -i '' -e '/VERSION_NAME/s/$/-SNAPSHOT/' "$file"
# Publish the plugin to the Sonatype snapshot repository
- name: Publish Snapshot
run: ./gradlew publishAllPublicationsToMavenCentralRepository
update_draft_release:
name: Create or Update Draft Release
runs-on: ubuntu-latest
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^VERSION_NAME:" | cut -f2- -d ' ')"
chmod +x ./get_changelog.sh
CHANGELOG="$(./get_changelog.sh)"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT
# Remove old release drafts by using the curl request for the available releases with a draft flag
- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/releases \
--jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
# Create a new release draft which is not publicly visible and requires manual acceptance
- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ steps.properties.outputs.version }} \
--draft \
--title "v${{ steps.properties.outputs.version }}" \
--notes "${{ steps.properties.outputs.changelog }}" \