-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (68 loc) · 2.37 KB
/
build-plugin.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
name: Build Plugin and Create Release
on:
push:
branches:
- master
env:
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission to gradlew
run: chmod +x gradlew
- name: Build plugin
run: $GITHUB_WORKSPACE/gradlew buildPlugin
- name: Get plugin file path
id: get_plugin_file
run: echo "::set-output name=plugin_file::$(find ${{ github.workspace }}/build/distributions -name '*.zip' -type f)"
- name: Archive plugin
run: mv ${{ steps.get_plugin_file.outputs.plugin_file }} ${{ github.workspace }}/plugin.zip
- name: Generate version number
id: version
run: |
DATE=$(date +'%Y%m%d')
RELEASES=$(curl -s -H "Authorization: Bearer ${{ secrets.MY_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases")
VERSION="v${DATE}.1"
if [[ $RELEASES == *"$VERSION"* ]]; then
COUNT=2
while [[ $RELEASES == *"${VERSION%.*}.${COUNT}"* ]]; do
COUNT=$((COUNT + 1))
done
VERSION="${VERSION%.*}.${COUNT}"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.MY_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
body: |
Release ${{ env.VERSION }}
draft: false
prerelease: false
- name: Upload plugin artifact
uses: actions/upload-artifact@v4
with:
name: plugin
path: plugin.zip
- name: Attach plugin artifact to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.MY_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/plugin.zip
asset_name: plugin.zip
asset_content_type: application/zip