Release 1.10.1 #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Plugin | |
run-name: Release ${{ inputs.release_version }} | |
#Only one job at a time | |
concurrency: release | |
on: | |
workflow_dispatch: | |
inputs: | |
publishToMarketPlace: | |
description: 'Publish to JetBrains Marketplace ?' | |
required: true | |
type: choice | |
options: | |
- 'true' | |
- 'false' | |
default: 'false' | |
release_version: | |
description: 'Release version' | |
required: true | |
type: string | |
jobs: | |
# Prepare and publish the plugin to JetBrains Marketplace repository | |
release: | |
name: Publish new release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
# Check out current repository | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
# Set up Java environment for the next steps | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
# Setup Gradle | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 #v3.5.0 | |
with: | |
add-job-summary: 'on-failure' | |
add-job-summary-as-pr-comment: 'on-failure' | |
validate-wrappers: true | |
gradle-home-cache-cleanup: true | |
- name: Tag Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Action" | |
if git diff --quiet; then | |
echo "No changes to commit." | |
else | |
git commit -sam "chore(skip-release): set version to ${{ inputs.release_version }}" | |
fi | |
git tag ${{ inputs.release_version }} | |
git push origin ${{ inputs.release_version }} | |
- name: Set Release Version | |
shell: bash | |
run: | | |
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2) | |
NEW_VERSION=${{ inputs.release_version }}.${{ github.run_number }} | |
awk -v current="$CURRENT_VERSION" -v new="$NEW_VERSION" 'BEGIN {FS=OFS="="} $1 == "projectVersion" { $2 = new }1' gradle.properties > tmpfile && mv tmpfile gradle.properties | |
echo "Release version: $NEW_VERSION" | |
echo "PLUGIN_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
# Publish the plugin to JetBrains Marketplace | |
- name: Publish Plugin to JetBrains Marketplace | |
if: ${{ inputs.publishToMarketPlace == 'true' }} | |
env: | |
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} | |
run: | | |
./gradlew publishPlugin -PjetBrainsToken=$PUBLISH_TOKEN -PprojectVersion=$PLUGIN_VERSION -PjetBrainsChannel=stable | |
echo "Published $PLUGIN_VERSION to the Jetbrains Marketplace" | |
# Set next SNAPSHOT version | |
- name: Increment Plugin Version | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
CURRENT_VERSION=$(grep "projectVersion=" gradle.properties | cut -d'=' -f2) | |
IFS="-" read -ra VERSION_PARTS <<< "$CURRENT_VERSION" | |
IFS="." read -ra VERSION_NUM <<< "${VERSION_PARTS[0]}" | |
((VERSION_NUM[2]+=1)) | |
NEW_VERSION="${VERSION_NUM[0]}.${VERSION_NUM[1]}.${VERSION_NUM[2]}-SNAPSHOT" | |
awk -v new_version="$NEW_VERSION" '/projectVersion=/{sub(/=.*/, "=" new_version)}1' gradle.properties > tmpfile && mv tmpfile gradle.properties | |
echo "Set $NEW_VERSION in gradle.properties" | |
git checkout -b $NEW_VERSION | |
git commit -sam "chore(skip-release): set version to $NEW_VERSION" | |
git push -u origin $NEW_VERSION | |
gh pr create -B main -H $NEW_VERSION --title "chore(skip-release): set version to $NEW_VERSION" --body 'Created by Github action' | |
- name: Simple conventional changelog | |
uses: redhat-developer/simple-conventional-changelog@0a6db1ac3910c2cf66f2e1a530951dba1ece8540 #0.0.12 | |
id: changelog | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
current-tag: ${{ inputs.release_version }} | |
types-mapping: 'feat:Features,fix:Bug Fixes,docs:Documentation,refactor:Refactoring,build:Builds,chore:Other' | |
# Create a new Github release | |
- name: Create Github Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ inputs.release_version }} \ | |
--title "${{ inputs.release_version }}" \ | |
--notes "$(cat << 'EOM' | |
${{ steps.changelog.outputs.changelog }} | |
EOM | |
)" | |
- name: Upload Release Asset | |
if: ${{ inputs.publishToMarketPlace == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release upload ${{ inputs.release_version }} ./build/distributions/* |