1+ name : Build
2+ on :
3+ # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
4+ push :
5+ branches : [ main ]
6+ # Trigger the workflow on any pull request
7+ pull_request :
8+
9+ jobs :
10+
11+ # Run Gradle Wrapper Validation Action to verify the wrapper's checksum
12+ # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
13+ # Build plugin and provide the artifact for the next workflow jobs
14+ build :
15+ name : Build
16+ runs-on : ubuntu-latest
17+ outputs :
18+ version : ${{ steps.properties.outputs.version }}
19+ changelog : ${{ steps.properties.outputs.changelog }}
20+ steps :
21+
22+ # Check out current repository
23+ - name : Fetch Sources
24+ uses : actions/checkout@v2.4.0
25+
26+ # Validate wrapper
27+ - name : Gradle Wrapper Validation
28+ uses : gradle/wrapper-validation-action@v1.0.4
29+
30+ # Setup Java 11 environment for the next steps
31+ - name : Setup Java
32+ uses : actions/setup-java@v2
33+ with :
34+ distribution : zulu
35+ java-version : 11
36+ cache : gradle
37+
38+ # Set environment variables
39+ - name : Export Properties
40+ id : properties
41+ shell : bash
42+ run : |
43+ PROPERTIES="$(./gradlew properties --console=plain -q)"
44+ VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
45+ NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
46+ CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
47+ CHANGELOG="${CHANGELOG//'%'/'%25'}"
48+ CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
49+ CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
50+ echo "::set-output name=version::$VERSION"
51+ echo "::set-output name=name::$NAME"
52+ echo "::set-output name=changelog::$CHANGELOG"
53+ echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
54+ ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
55+
56+ # Cache Plugin Verifier IDEs
57+ - name : Setup Plugin Verifier IDEs Cache
58+ uses : actions/cache@v2.1.7
59+ with :
60+ path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
61+ key : plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
62+
63+ # Run Verify Plugin task and IntelliJ Plugin Verifier tool
64+ - name : Run Plugin Verification tasks
65+ run : ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
66+
67+ # Collect Plugin Verifier Result
68+ - name : Collect Plugin Verifier Result
69+ if : ${{ always() }}
70+ uses : actions/upload-artifact@v2
71+ with :
72+ name : pluginVerifier-result
73+ path : ${{ github.workspace }}/build/reports/pluginVerifier
74+
75+ # Prepare plugin archive content for creating artifact
76+ - name : Prepare Plugin Artifact
77+ id : artifact
78+ shell : bash
79+ run : |
80+ cd ${{ github.workspace }}/build/distributions
81+ FILENAME=`ls *.zip`
82+ unzip "$FILENAME" -d content
83+ echo "::set-output name=filename::${FILENAME:0:-4}"
84+ # Store already-built plugin as an artifact for downloading
85+ - name : Upload artifact
86+ uses : actions/upload-artifact@v2.2.4
87+ with :
88+ name : ${{ steps.artifact.outputs.filename }}
89+ path : ./build/distributions/content/*/*
90+
91+ # Prepare a draft release for GitHub Releases page for the manual verification
92+ # If accepted and published, release workflow would be triggered
93+ releaseDraft :
94+ name : Release Draft
95+ if : github.event_name != 'pull_request'
96+ needs : build
97+ runs-on : ubuntu-latest
98+ steps :
99+
100+ # Check out current repository
101+ - name : Fetch Sources
102+ uses : actions/checkout@v2.4.0
103+
104+ # Remove old release drafts by using the curl request for the available releases with draft flag
105+ - name : Remove Old Release Drafts
106+ env :
107+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108+ run : |
109+ gh api repos/{owner}/{repo}/releases \
110+ --jq '.[] | select(.draft == true) | .id' \
111+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
112+ # Create new release draft - which is not publicly visible and requires manual acceptance
113+ - name : Create Release Draft
114+ env :
115+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
116+ run : |
117+ gh release create v${{ needs.build.outputs.version }} \
118+ --draft \
119+ --title "v${{ needs.build.outputs.version }}" \
120+ --notes "$(cat << 'EOM'
121+ ${{ needs.build.outputs.changelog }}
122+ EOM
123+ )"
0 commit comments