Skip to content

Commit

Permalink
Add special LATEST keyword to use the latest version of `intellij-p…
Browse files Browse the repository at this point in the history
…lugin-verifier` based on the released version on GitHub.

Prepare for v0.0.2 release to GitHub Marketplace.

Fixes #3
  • Loading branch information
ChrisCarini committed Apr 21, 2020
1 parent 62a4064 commit 5c5775c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 23 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# Ref: https://hub.docker.com/layers/openjdk/library/openjdk/8-jdk-alpine/images/sha256-210ecd2595991799526a62a7099718b149e3bbefdb49764cc2a450048e0dd4c0?context=explore
FROM openjdk:8-jdk-alpine

# We need jq to find the latest version of the verifier jar
RUN apk --no-cache add jq

# We need curl to download the verifier jar
RUN apk --no-cache add curl

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# IntelliJ Platform Plugin Verifier Action
A [GitHub Action](https://help.github.com/en/actions) for executing the [JetBrains intellij-plugin-verifier](https://github.com/JetBrains/intellij-plugin-verifier).

[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-v0.0.1-blue.svg?logo=github&logoColor=white&style=flat)](https://github.com/marketplace/actions/intellij-platform-plugin-verifier)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-v0.0.2-blue.svg?logo=github&logoColor=white&style=flat)](https://github.com/marketplace/actions/intellij-platform-plugin-verifier)

# Usage
Add the action to your [GitHub Action Workflow file](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#creating-a-workflow-file) - the only thing you _need_ to specify are the JetBrains products & versions you wish to run against.

A minimal example of a workflow step is below:
```yaml
- name: Verify Plugin on IntelliJ Platforms
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.1
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.2
with:
ide-versions: |
ideaIC:2019.3
Expand Down Expand Up @@ -43,7 +43,7 @@ A minimal example of a workflow step is below:
- name: Verify Plugin on IntelliJ Platforms
id: verify
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.1
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.2
with:
ide-versions: |
ideaIC:2019.3
Expand All @@ -64,16 +64,16 @@ A minimal example of a workflow step is below:
This GitHub Action exposes 3 input options, only one of which is required.

| Input | Description | Usage | Default |
| :---: | :--------: | :---: | :-----: |
| `verifier-version` | The version of the [JetBrains intellij-plugin-verifier](https://github.com/JetBrains/intellij-plugin-verifier) | *Optional* | `1.231` |
| :---: | :--------- | :---: | :-----: |
| `verifier-version` | The version of the [JetBrains intellij-plugin-verifier](https://github.com/JetBrains/intellij-plugin-verifier). The default of `LATEST` will automatically pull the most recently released version from GitHub - a specific version of the `intellij-plugin-verifier` can be optionally be pinned if desired. | *Optional* | `LATEST` |
| `plugin-location` | The path to the `zip`-distribution of the plugin(s), generated by executing `./gradlew buildPlugin` | *Optional* | `build/distributions/*.zip` |
| `ide-versions` | Releases of IntelliJ Platform IDEs and versions that should be used to validate against, formatted as a multi-line string as shown in the examples. Formatted as `<ide>:<version>` - see below for details. | *Required* | |

An example using all the available options is below:
```yaml
- name: Verify Plugin on IntelliJ Platforms
id: verify
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.1
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.2
with:
verifier-version: '1.230'
plugin-location: 'build/distributions/sample-intellij-plugin-*.zip'
Expand All @@ -83,17 +83,17 @@ An example using all the available options is below:

### `verifier-version`

This option is exposed to allow users to override the default.
This optional input allows users to pin a specific version of `intellij-plugin-verifier` to be used during validation.

### `plugin-location`

This option is exposed to allow users to specify a different location for the plugin(s) `.zip` file. The default
This optional input allows users to specify a different location for the plugin(s) `.zip` file. The default
assumes that [gradle-intellij-plugin](https://github.com/JetBrains/gradle-intellij-plugin/) is being used to build
the plugin(s).
the plugin(s).

### `ide-versions`

This option is required to set which IDEs and versions are desired to be validated.
This required input sets which IDEs and versions the plugins will be validated against.

You can identify the value for `<ide>` and `<version>` as follows.

Expand Down Expand Up @@ -152,7 +152,7 @@ In the below example, we use set the `id` to `verify` - this example will print
```yaml
- name: Verify Plugin on IntelliJ Platforms
id: verify
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.1
uses: ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.2
with:
ide-versions: |
ideaIC:2019.3
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ inputs:
description: 'The version of verifier-all.jar to download and use for verification.'
required: true
# Find the latest version here: https://bintray.com/jetbrains/intellij-plugin-service/intellij-plugin-verifier
default: '1.236' # 1.236 was published on 2020-04-17
# and the latest GitHub tagged version here: https://github.com/JetBrains/intellij-plugin-verifier/tags
#
# `LATEST` is a special, internal, keyword to signal our script to automatically resolve the latest tagged version
# from the GH repo of the intellij-plugin-verifier -> https://github.com/JetBrains/intellij-plugin-verifier/tags
# This option is presented to people in case they wish to explicitly override the version of the plugin verifier.
default: 'LATEST'
plugin-location:
description: 'The location of the plugin; based from the root directory of your project; ie: `build/distributions/sample-intellij-plugin-*`'
required: true
Expand Down
44 changes: 33 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -eu
# GitHub Debug Function
##
gh_debug() {
if (( $# == 0 )) ; then
if [[ "$#" -eq 0 ]] ; then
while read line; do
echo "::debug::${line}"
done
Expand Down Expand Up @@ -72,6 +72,34 @@ echo "$INPUT_IDE_VERSIONS" | while read -r INPUT_IDE_VERSION; do
gh_debug " => $INPUT_IDE_VERSION"
done


##
# Resolve verifier values
##
if [[ "$INPUT_VERIFIER_VERSION" == "LATEST" ]]; then
gh_debug "LATEST verifier version found, resolving version..."
GH_LATEST_RELEASE_FILE="$HOME/intellij-plugin-verifier_latest_gh_release.json"
curl -s https://api.github.com/repos/JetBrains/intellij-plugin-verifier/releases/latest > "$GH_LATEST_RELEASE_FILE"
VERIFIER_VERSION=$(cat "$GH_LATEST_RELEASE_FILE" | jq -r .tag_name | sed 's/[^[:digit:].]*//g')
VERIFIER_DOWNLOAD_URL=$(cat "$GH_LATEST_RELEASE_FILE" | jq -r .assets[].browser_download_url)
VERIFIER_JAR_FILENAME=$(cat "$GH_LATEST_RELEASE_FILE" | jq -r .assets[].name)
else
gh_debug "Using verifier version [$INPUT_VERIFIER_VERSION]..."

VERIFIER_VERSION=${INPUT_VERIFIER_VERSION}
VERIFIER_DOWNLOAD_URL="https://dl.bintray.com/jetbrains/intellij-plugin-service/org/jetbrains/intellij/plugins/verifier-cli/$INPUT_VERIFIER_VERSION/$VERIFIER_JAR_FILENAME"
# The filename of the `verifier-cli-*-all.jar` file
VERIFIER_JAR_FILENAME="verifier-cli-$VERIFIER_VERSION-all.jar"
fi

# The full path of the `verifier-cli-*-all.jar` file
VERIFIER_JAR_LOCATION="$HOME/$VERIFIER_JAR_FILENAME"

gh_debug "VERIFIER_VERSION => $VERIFIER_VERSION"
gh_debug "VERIFIER_DOWNLOAD_URL => $VERIFIER_DOWNLOAD_URL"
gh_debug "VERIFIER_JAR_FILENAME => $VERIFIER_JAR_FILENAME"
gh_debug "VERIFIER_JAR_LOCATION => $VERIFIER_JAR_LOCATION"

##
# Other Variables
##
Expand All @@ -81,12 +109,6 @@ done
# and pull the `JAVA_HOME` property from it's image (ie, its definition has `ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk`).
JAVA_HOME="/usr/lib/jvm/java-1.8-openjdk"

# The filename of the `verifier-cli-*-all.jar` file
VERIFIER_JAR_FILENAME="verifier-cli-$INPUT_VERIFIER_VERSION-all.jar"

# The full path of the `verifier-cli-*-all.jar` file
VERIFIER_JAR_LOCATION="$HOME/$VERIFIER_JAR_FILENAME"

# The location of the plugin
PLUGIN_LOCATION="$GITHUB_WORKSPACE/$INPUT_PLUGIN_LOCATION"

Expand Down Expand Up @@ -124,8 +146,8 @@ release_type_for() {
# Setup
##

echo "Downloading plugin verifier ($VERIFIER_JAR_FILENAME) [version '$INPUT_VERIFIER_VERSION']..."
curl -L --output "$VERIFIER_JAR_LOCATION" "https://dl.bintray.com/jetbrains/intellij-plugin-service/org/jetbrains/intellij/plugins/verifier-cli/$INPUT_VERIFIER_VERSION/$VERIFIER_JAR_FILENAME"
echo "Downloading plugin verifier [version '$INPUT_VERIFIER_VERSION'] from [$VERIFIER_DOWNLOAD_URL] to [$VERIFIER_JAR_LOCATION]..."
curl -L --output "$VERIFIER_JAR_LOCATION" "$VERIFIER_DOWNLOAD_URL"

# temp file for storing IDE Directories we download and unzip
tmp_ide_directories="/tmp/ide_directories.txt"
Expand Down Expand Up @@ -162,7 +184,7 @@ echo "$INPUT_IDE_VERSIONS" | while read -r IDE_VERSION; do
mkdir -p "$IDE_EXTRACT_LOCATION"
unzip -q -d "$IDE_EXTRACT_LOCATION" "$ZIP_FILE_PATH"

gh_debug "::debug::Removing [$ZIP_FILE_PATH] to save storage space..."
gh_debug "Removing [$ZIP_FILE_PATH] to save storage space..."
rm "$ZIP_FILE_PATH"

# Append the extracted location to the variable of IDEs to validate against.
Expand Down Expand Up @@ -217,7 +239,7 @@ java -jar "$VERIFIER_JAR_LOCATION" check-plugin $PLUGIN_LOCATION $IDE_DIRECTORIE

echo "::set-output name=verification-output-log-filename::$VERIFICATION_OUTPUT_LOG"

# Validate the log; fail if we find compatability problems.
# Validate the log; fail if we find compatibility problems.
if (grep -E -q "^Plugin (.*) against .*: .* compatibility problems?$" "$VERIFICATION_OUTPUT_LOG"); then
echo "::error::=============================================="
echo "::error::=============================================="
Expand Down

0 comments on commit 5c5775c

Please sign in to comment.