@@ -3,6 +3,9 @@ name: Build Plugin JAR File
3
3
on :
4
4
push :
5
5
branches : [ main ]
6
+ release :
7
+ types :
8
+ - created
6
9
7
10
jobs :
8
11
build :
43
46
./gradlew pnpmInstall
44
47
- name : Build with Gradle
45
48
run : |
49
+ # Set the version with tag name when releasing
50
+ version=${{ github.event.release.tag_name }}
51
+ version=${version#v}
52
+ sed -i "s/version=.*-SNAPSHOT$/version=$version/1" gradle.properties
46
53
./gradlew clean build -x test
47
54
- name : Archive plugin-umami jar
48
55
uses : actions/upload-artifact@v2
51
58
path : |
52
59
build/libs/*-plain.jar
53
60
retention-days : 1
61
+
62
+ github-release :
63
+ runs-on : ubuntu-latest
64
+ needs : build
65
+ if : github.event_name == 'release'
66
+ steps :
67
+ - name : Download plugin-umami jar
68
+ uses : actions/download-artifact@v2
69
+ with :
70
+ name : plugin-umami
71
+ path : build/libs
72
+ - name : Get Name of Artifact
73
+ id : get_artifact
74
+ run : |
75
+ ARTIFACT_PATHNAME=$(ls build/libs/*.jar | head -n 1)
76
+ ARTIFACT_NAME=$(basename ${ARTIFACT_PATHNAME})
77
+ echo "Artifact pathname: ${ARTIFACT_PATHNAME}"
78
+ echo "Artifact name: ${ARTIFACT_NAME}"
79
+ echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV
80
+ echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
81
+ echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV
82
+ - name : Upload a Release Asset
83
+ uses : actions/github-script@v2
84
+ if : github.event_name == 'release'
85
+ with :
86
+ github-token : ${{secrets.GITHUB_TOKEN}}
87
+ script : |
88
+ console.log('environment', process.versions);
89
+
90
+ const fs = require('fs').promises;
91
+
92
+ const { repo: { owner, repo }, sha } = context;
93
+ console.log({ owner, repo, sha });
94
+
95
+ const releaseId = process.env.RELEASE_ID
96
+ const artifactPathName = process.env.ARTIFACT_PATHNAME
97
+ const artifactName = process.env.ARTIFACT_NAME
98
+ console.log('Releasing', releaseId, artifactPathName, artifactName)
99
+
100
+ await github.repos.uploadReleaseAsset({
101
+ owner, repo,
102
+ release_id: releaseId,
103
+ name: artifactName,
104
+ data: await fs.readFile(artifactPathName)
105
+ });
0 commit comments