Skip to content

Commit d9c84b3

Browse files
authored
Move from Travis to GitHub Actions (#352)
Since Travis CI will shut down, this migrates the plugin builds to the official JetBrains Plugin Template. It builds and deploys the plugin on GitHub release, through GitHub Actions. The main challenge is to adapt the multi-version build to the official template.
1 parent 87a7052 commit d9c84b3

File tree

18 files changed

+529
-231
lines changed

18 files changed

+529
-231
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ trim_trailing_whitespace = false
1717

1818
[*.bnf]
1919
indent_size = 2
20+
21+
[*.yml]
22+
indent_size = 2

.github/workflows/build.yml

Lines changed: 342 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,342 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Build
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
10+
gradleValidation:
11+
name: Gradle Wrapper
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
# Check out current repository
16+
- name: Fetch Sources
17+
uses: actions/checkout@v2
18+
19+
# Validate wrapper
20+
- name: Gradle Wrapper Validation
21+
uses: gradle/wrapper-validation-action@v1.0.3
22+
23+
# Run verifyPlugin and test Gradle tasks
24+
test:
25+
name: Test
26+
needs: gradleValidation
27+
runs-on: ubuntu-latest
28+
29+
env:
30+
ORG_GRADLE_PROJECT_ideaVersion: "${{ matrix.idea_version }}"
31+
ORG_GRADLE_PROJECT_phpPluginVersion: "${{ matrix.php_plugin_version }}"
32+
ORG_GRADLE_PROJECT_psiViewerPluginVersion: "${{ matrix.psi_viewer_plugin_version }}"
33+
ORG_GRADLE_PROJECT_grammarKitPluginVersion: "${{ matrix.grammar_kit_plugin_version }}"
34+
ORG_GRADLE_PROJECT_customSinceBuild: "${{ matrix.since_build }}"
35+
ORG_GRADLE_PROJECT_customUntilBuild: "${{ matrix.until_build }}"
36+
37+
strategy:
38+
matrix:
39+
include:
40+
- idea_version: "IU-2020.3.3"
41+
java_version: "1.11"
42+
php_plugin_version: "203.7148.15"
43+
psi_viewer_plugin_version: "203-SNAPSHOT"
44+
grammar_kit_plugin_version: "2020.2.1"
45+
since_build: "203"
46+
until_build: "203.*"
47+
- idea_version: "IU-2021.1"
48+
java_version: "1.11"
49+
php_plugin_version: "211.6693.120"
50+
psi_viewer_plugin_version: "211-SNAPSHOT"
51+
grammar_kit_plugin_version: "2020.2.1"
52+
since_build: "211"
53+
until_build: "211.*"
54+
55+
steps:
56+
57+
- name: Setup Java
58+
uses: actions/setup-java@v1
59+
with:
60+
java-version: ${{ matrix.java_version }}
61+
62+
# Check out current repository
63+
- name: Fetch Sources
64+
uses: actions/checkout@v2
65+
66+
# Cache Gradle Dependencies
67+
- name: Setup Gradle Dependencies Cache
68+
uses: actions/cache@v2
69+
with:
70+
path: ~/.gradle/caches
71+
key: ${{ runner.os }}-${{ matrix.idea_version }}-${{ matrix.php_plugin_version }}-gradle-caches-${{ hashFiles('**/*.gradle', 'gradle.properties') }}
72+
73+
# Cache Gradle Wrapper
74+
- name: Setup Gradle Wrapper Cache
75+
uses: actions/cache@v2
76+
with:
77+
path: ~/.gradle/wrapper
78+
key: ${{ runner.os }}-${{ matrix.idea_version }}-${{ matrix.php_plugin_version }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
79+
80+
# Run detekt, ktlint and tests
81+
- name: Run Linters and Test
82+
run: ./gradlew check
83+
84+
# Run verifyPlugin Gradle task
85+
- name: Verify Plugin
86+
run: ./gradlew verifyPlugin
87+
88+
build:
89+
name: Build
90+
needs: test
91+
92+
env:
93+
ORG_GRADLE_PROJECT_ideaVersion: "${{ matrix.idea_version }}"
94+
ORG_GRADLE_PROJECT_phpPluginVersion: "${{ matrix.php_plugin_version }}"
95+
ORG_GRADLE_PROJECT_psiViewerPluginVersion: "${{ matrix.psi_viewer_plugin_version }}"
96+
ORG_GRADLE_PROJECT_grammarKitPluginVersion: "${{ matrix.grammar_kit_plugin_version }}"
97+
ORG_GRADLE_PROJECT_customSinceBuild: "${{ matrix.since_build }}"
98+
ORG_GRADLE_PROJECT_customUntilBuild: "${{ matrix.until_build }}"
99+
100+
runs-on: ubuntu-latest
101+
102+
strategy:
103+
matrix:
104+
include:
105+
- idea_version: "IU-2020.3.3"
106+
java_version: "1.11"
107+
php_plugin_version: "203.7148.15"
108+
psi_viewer_plugin_version: "203-SNAPSHOT"
109+
grammar_kit_plugin_version: "2020.2.1"
110+
since_build: "203"
111+
until_build: "203.*"
112+
- idea_version: "IU-2021.1"
113+
java_version: "1.11"
114+
php_plugin_version: "211.6693.120"
115+
psi_viewer_plugin_version: "211-SNAPSHOT"
116+
grammar_kit_plugin_version: "2020.2.1"
117+
since_build: "211"
118+
until_build: "211.*"
119+
120+
outputs:
121+
cms-name: ${{ steps.properties.outputs.cms-name }}
122+
fluid-name: ${{ steps.properties.outputs.fluid-name }}
123+
typoscript-name: ${{ steps.properties.outputs.typoscript-name }}
124+
version: ${{ steps.properties.outputs.version }}
125+
prefixed-version: ${{ steps.properties.outputs.prefixed-version }}
126+
changelog: ${{ steps.properties.outputs.changelog }}
127+
cms-artifact: ${{ steps.properties.outputs.cms-artifact }}
128+
fluid-artifact: ${{ steps.properties.outputs.fluid-artifact }}
129+
typoscript-artifact: ${{ steps.properties.outputs.typoscript-artifact }}
130+
131+
steps:
132+
- uses: actions/checkout@v2
133+
- name: Set up JDK
134+
uses: actions/setup-java@v1
135+
with:
136+
java-version: ${{ matrix.java_version }}
137+
138+
# Cache Gradle Dependencies
139+
- name: Setup Gradle Dependencies Cache
140+
uses: actions/cache@v2
141+
with:
142+
path: ~/.gradle/caches
143+
key: ${{ runner.os }}-${{ matrix.idea_version }}-${{ matrix.php_plugin_version }}-gradle-caches-${{ hashFiles('**/*.gradle', 'gradle.properties') }}
144+
145+
# Cache Gradle Wrapper
146+
- name: Setup Gradle Wrapper Cache
147+
uses: actions/cache@v2
148+
with:
149+
path: ~/.gradle/wrapper
150+
key: ${{ runner.os }}-${{ matrix.idea_version }}-${{ matrix.php_plugin_version }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
151+
152+
# Set environment variables
153+
- name: Export Properties
154+
id: properties
155+
shell: bash
156+
run: |
157+
PROPERTIES="$(./gradlew properties --console=plain -q)"
158+
VERSION="$(echo "$PROPERTIES" | grep "^pluginVersion:" | cut -f2- -d ' ')"
159+
CUSTOM_SINCE_BUILD="$(echo "$PROPERTIES" | grep "^customSinceBuild:" | cut -f2- -d ' ')"
160+
PREFIXED_VERSION="$(echo ${CUSTOM_SINCE_BUILD}${VERSION:1})"
161+
162+
CMS_NAME="$(echo "$PROPERTIES" | grep "^pluginNameCMS:" | cut -f2- -d ' ')"
163+
FLUID_NAME="$(echo "$PROPERTIES" | grep "^pluginNameFluid:" | cut -f2- -d ' ')"
164+
TYPOSCRIPT_NAME="$(echo "$PROPERTIES" | grep "^pluginNameTypoScript:" | cut -f2- -d ' ')"
165+
166+
CHANGELOG="$(./gradlew :getChangelog --unreleased --no-header --console=plain -q)"
167+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
168+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
169+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
170+
171+
CMS_ARTIFACT="${CMS_NAME}-${PREFIXED_VERSION}.zip"
172+
FLUID_ARTIFACT="${FLUID_NAME}-${PREFIXED_VERSION}.zip"
173+
TYPOSCRIPT_ARTIFACT="${TYPOSCRIPT_NAME}-${PREFIXED_VERSION}.zip"
174+
175+
echo "::set-output name=version::$VERSION"
176+
echo "::set-output name=prefixed-version::$PREFIXED_VERSION"
177+
echo "::set-output name=cms-name::$CMS_NAME"
178+
echo "::set-output name=fluid-name::$FLUID_NAME"
179+
echo "::set-output name=typoscript-name::$TYPOSCRIPT_NAME"
180+
echo "::set-output name=changelog::$CHANGELOG"
181+
echo "::set-output name=cms-artifact::$CMS_ARTIFACT"
182+
echo "::set-output name=fluid-artifact::$FLUID_ARTIFACT"
183+
echo "::set-output name=typoscript-artifact::$TYPOSCRIPT_ARTIFACT"
184+
185+
# Build artifact using buildPlugin Gradle task
186+
- name: Build Plugin
187+
shell: bash
188+
run: |
189+
# Set output from previous step
190+
export "ORG_GRADLE_PROJECT_pluginVersion=${{ steps.properties.outputs.prefixed-version }}"
191+
192+
./gradlew buildPlugin
193+
194+
# Upload plugin artifact to make it available in the next jobs
195+
- name: Upload CMS artifact
196+
uses: actions/upload-artifact@v2.2.3
197+
with:
198+
name: cms-plugin-artifact-${{ matrix.since_build }}
199+
path: ./typo3-cms/build/distributions/${{ steps.properties.outputs.cms-artifact }}
200+
if-no-files-found: error
201+
- name: Upload Fluid artifact
202+
uses: actions/upload-artifact@v2.2.3
203+
with:
204+
name: fluid-plugin-artifact-${{ matrix.since_build }}
205+
path: ./lang-fluid/build/distributions/${{ steps.properties.outputs.fluid-artifact }}
206+
if-no-files-found: error
207+
- name: Upload TypoScript artifact
208+
uses: actions/upload-artifact@v2.2.3
209+
with:
210+
name: typoscript-plugin-artifact-${{ matrix.since_build }}
211+
path: ./lang-typoscript/build/distributions/${{ steps.properties.outputs.typoscript-artifact }}
212+
if-no-files-found: error
213+
214+
# Verify built plugin using IntelliJ Plugin Verifier tool
215+
# Requires build job to be passed
216+
verify:
217+
name: Verify
218+
needs: build
219+
runs-on: ubuntu-latest
220+
steps:
221+
222+
# Setup Java 1.8 environment for the next steps
223+
- name: Setup Java
224+
uses: actions/setup-java@v1
225+
with:
226+
java-version: 1.8
227+
228+
# Check out current repository
229+
- name: Fetch Sources
230+
uses: actions/checkout@v2
231+
232+
# Cache Gradle Dependencies
233+
- name: Setup Gradle Dependencies Cache
234+
uses: actions/cache@v2
235+
with:
236+
path: ~/.gradle/caches
237+
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
238+
239+
# Cache Gradle Wrapper
240+
- name: Setup Gradle Wrapper Cache
241+
uses: actions/cache@v2
242+
with:
243+
path: ~/.gradle/wrapper
244+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
245+
246+
# Set environment variables
247+
- name: Export Properties
248+
id: properties
249+
shell: bash
250+
run: |
251+
PROPERTIES="$(./gradlew properties --console=plain -q)"
252+
IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
253+
echo "::set-output name=ideVersions::$IDE_VERSIONS"
254+
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
255+
# Cache Plugin Verifier IDEs
256+
- name: Setup Plugin Verifier IDEs Cache
257+
uses: actions/cache@v2
258+
with:
259+
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
260+
key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
261+
262+
# Prepare a draft release for GitHub Releases page for the manual verification
263+
# If accepted and published, release workflow would be triggered
264+
releaseDraft:
265+
name: Release Draft
266+
if: github.event_name != 'pull_request' # && github.ref == 'refs/heads/master'
267+
needs: [ build, verify ]
268+
runs-on: ubuntu-latest
269+
270+
outputs:
271+
release-url: ${{ steps.createDraft.outputs.upload_url }}
272+
273+
steps:
274+
275+
# Check out current repository
276+
- name: Fetch Sources
277+
uses: actions/checkout@v2
278+
279+
# Remove old release drafts by using the curl request for the available releases with draft flag
280+
- name: Remove Old Release Drafts
281+
env:
282+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
283+
run: |
284+
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
285+
| tr '\r\n' ' ' \
286+
| jq '.[] | select(.draft == true) | .id' \
287+
| xargs -I '{}' \
288+
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
289+
290+
# Create new release draft - which is not publicly visible and requires manual acceptance
291+
- name: Create Release Draft
292+
id: createDraft
293+
uses: actions/create-release@v1
294+
env:
295+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
296+
with:
297+
tag_name: v${{ needs.build.outputs.version }}
298+
release_name: v${{ needs.build.outputs.version }}
299+
body: ${{ needs.build.outputs.changelog }}
300+
draft: true
301+
302+
releaseDraftUpload:
303+
name: Release Draft (Upload)
304+
if: github.event_name != 'pull_request' # && github.ref == 'refs/heads/master'
305+
needs: [ releaseDraft ]
306+
runs-on: ubuntu-latest
307+
308+
strategy:
309+
matrix:
310+
include:
311+
- since_build: "203"
312+
- since_build: "211"
313+
314+
steps:
315+
316+
# Check out current repository
317+
- name: Fetch Sources
318+
uses: actions/checkout@v2
319+
320+
# Download plugin artifact provided by the previous job
321+
- name: Download CMS Artifact
322+
uses: actions/download-artifact@v2
323+
with:
324+
name: cms-plugin-artifact-${{ matrix.since_build }}
325+
- name: Download Fluid Artifact
326+
uses: actions/download-artifact@v2
327+
with:
328+
name: fluid-plugin-artifact-${{ matrix.since_build }}
329+
- name: Download TypoScript Artifact
330+
uses: actions/download-artifact@v2
331+
with:
332+
name: typoscript-plugin-artifact-${{ matrix.since_build }}
333+
334+
# Upload artifact as a release asset
335+
- name: Upload Release Assets
336+
id: upload-release-asset
337+
uses: shogo82148/actions-upload-release-asset@v1
338+
env:
339+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
340+
with:
341+
upload_url: ${{ needs.releaseDraft.outputs.release-url }}
342+
asset_path: '*.zip'

.github/workflows/gradle-wrapper-validation.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)