1+ name : release
2+ on :
3+ workflow_dispatch :
4+ inputs :
5+ version :
6+ description : ' the version to be released'
7+ required : true
8+
9+ jobs :
10+ build-jar-job :
11+ name : ' Build JAR'
12+ runs-on : ubuntu-latest
13+ env :
14+ RELEASE_VERSION : ${{ github.event.inputs.version }}
15+
16+ steps :
17+ - name : ' Checkout'
18+ uses : actions/checkout@v2
19+
20+ - name : ' Setup Java 11'
21+ uses : actions/setup-java@v1
22+ with :
23+ java-version : 11
24+
25+ - name : ' Build JAR'
26+ run : |
27+ ./gradlew clean build shadowJar
28+
29+ - name : ' Publish JAR'
30+ uses : actions/upload-artifact@v2-preview
31+ with :
32+ name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all.jar'
33+ path : build/libs/*-all.jar
34+
35+ - name : ' Create Release'
36+ id : create_release
37+ uses : actions/create-release@v1
38+ env :
39+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
40+ with :
41+ tag_name : ' v${{env.RELEASE_VERSION}}'
42+ release_name : ' Version ${{env.RELEASE_VERSION}}'
43+ body : |
44+ New Release
45+ draft : false
46+ prerelease : false
47+
48+ - name : ' Upload Release Asset'
49+ id : upload-release-asset
50+ uses : actions/upload-release-asset@v1
51+ env :
52+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
53+ with :
54+ upload_url : ${{steps.create_release.outputs.upload_url}}
55+ asset_path : build/libs/graphql-anonymizer-${{env.RELEASE_VERSION}}-all.jar
56+ asset_name : graphql-anonymizer-${{env.RELEASE_VERSION}}-all.jar
57+ asset_content_type : application/java-archive
58+
59+
60+ - name : ' Write Upload URL To File'
61+ run : |
62+ echo "${{steps.create_release.outputs.upload_url}}" > upload_url.txt
63+
64+ - name : ' Publish Upload URL'
65+ uses : actions/upload-artifact@v2-preview
66+ with :
67+ name : ' upload_url.txt'
68+ path : ' upload_url.txt'
69+
70+ build-non-windows-image :
71+ name : ' Build Non-Windows Image'
72+ needs : [ build-jar-job ]
73+ strategy :
74+ matrix :
75+ os : [ 'ubuntu-latest', 'macos-latest' ]
76+ include :
77+ - os : ' ubuntu-latest'
78+ label : ' linux'
79+ - os : ' macos-latest'
80+ label : ' mac'
81+ runs-on : ${{matrix.os}}
82+ env :
83+ RELEASE_VERSION : ${{ github.event.inputs.version }}
84+
85+
86+ steps :
87+ - name : ' Checkout'
88+ uses : actions/checkout@v2
89+
90+ - name : ' Setup Java 11'
91+ uses : actions/setup-java@v1
92+ with :
93+ java-version : 11
94+
95+ - name : ' Setup GraalVM Environment'
96+ uses : DeLaGuardo/setup-graalvm@2.0
97+ with :
98+ graalvm-version : ' 21.1.0.2.java11'
99+
100+ - name : ' Install Native Image Plugin'
101+ run : |
102+ gu install native-image
103+
104+ - name : ' Get JAR Artifact'
105+ uses : actions/download-artifact@v2-preview
106+ with :
107+ name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all.jar'
108+
109+ - name : ' Get Release URL'
110+ uses : actions/download-artifact@v2-preview
111+ with :
112+ name : ' upload_url.txt'
113+
114+ - name : ' Get Upload URL'
115+ run : |
116+ echo "::set-env name=UPLOAD_URL::$(cat upload_url.txt)"
117+
118+ - name : ' Build Native Image'
119+ run : |
120+ native-image -H:+ReportExceptionStackTraces -H:+ReportUnsupportedElementsAtRuntime --verbose --no-server --no-fallback --allow-incomplete-classpath -jar graphql-anonymizer-${{env.RELEASEVERSION}}-all.jar
121+
122+ - name : ' Publish Native Image'
123+ if : success()
124+ uses : actions/upload-artifact@v2-preview
125+ with :
126+ name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-${{matrix.label}}'
127+ path : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all'
128+
129+ - name : ' Release Native Image Asset'
130+ if : success() && contains(github.ref, 'v')
131+ id : upload-release-asset
132+ uses : actions/upload-release-asset@v1
133+ env :
134+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
135+ with :
136+ upload_url : ${{env.UPLOAD_URL}}
137+ asset_name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-${{matrix.label}}'
138+ asset_path : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all'
139+ asset_content_type : application/octet-stream
140+
141+ build-windows-image :
142+ needs : [ build-jar-job ]
143+ name : ' Build Windows Image'
144+ runs-on : windows-latest
145+ env :
146+ RELEASE_VERSION : ${{ github.event.inputs.version }}
147+
148+
149+ steps :
150+
151+ - name : ' Checkout'
152+ uses : actions/checkout@v1
153+
154+ - name : ' Download GraalVM'
155+ run : |
156+ Invoke-RestMethod -Uri https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0.2/graalvm-ce-java11-windows-amd64-21.0.0.2.zip -OutFile 'graal.zip'
157+
158+ - name : ' Install GraalVM'
159+ run : |
160+ Expand-Archive -path 'graal.zip' -destinationpath '.'
161+
162+ - name : ' Install Native Image'
163+ run : |
164+ graalvm-ce-java11-21.0.0.2\bin\gu.cmd install native-image
165+
166+ - name : ' Set up Visual C Build Tools Workload for Visual Studio 2017 Build Tools'
167+ run : |
168+ choco install visualstudio2017-workload-vctools
169+
170+ - name : ' Get JAR Artifact'
171+ uses : actions/download-artifact@v2-preview
172+ with :
173+ name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all.jar'
174+
175+ - name : ' Build Native Image'
176+ shell : cmd
177+ env :
178+ JAVA_HOME : ./graalvm-ce-java11-21.0.0.2
179+ run : |
180+ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
181+ ./graalvm-ce-java11-21.0.0.2/bin/native-image --no-server --no-fallback -H:ReflectionConfigurationResources=reflection-config.json -H:IncludeResources=logback.xml -H:Name=graphql-anonymizer-${{env.RELEASE_VERSION}}-all --allow-incomplete-classpath -jar graphql-anonymizer-${{env.RELEASE_VERSION}}-all.jar
182+
183+ - name : ' Get Release URL'
184+ uses : actions/download-artifact@v2-preview
185+ with :
186+ name : ' upload_url.txt'
187+
188+ - name : ' Get Upload URL'
189+ run : |
190+ echo "::set-env name=UPLOAD_URL::$(cat upload_url.txt)"
191+ shell : bash
192+
193+ - name : ' Publish Windows Image'
194+ if : success()
195+ uses : actions/upload-artifact@v2-preview
196+ with :
197+ name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-windows.exe'
198+ path : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all.exe'
199+
200+ - name : ' Release Windows Image Asset'
201+ if : success()
202+ id : upload-release-asset
203+ uses : actions/upload-release-asset@v1
204+ env :
205+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
206+ with :
207+ upload_url : ${{env.UPLOAD_URL}}
208+ asset_name : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-windows.exe'
209+ asset_path : ' graphql-anonymizer-${{env.RELEASE_VERSION}}-all.exe'
210+ asset_content_type : application/octet-stream
0 commit comments