Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically publish GitHub release and to JetBrains Marketplace when new version tag is pushed. #9

Merged
merged 13 commits into from Mar 26, 2024
Merged
54 changes: 52 additions & 2 deletions .github/workflows/github-actions-CI.yml
@@ -1,9 +1,20 @@
name: CI
on: [push, pull_request]
on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- "v*"

jobs:
build:
ci:
name: test
runs-on: ubuntu-latest
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH }}

steps:
- name: Checkout repository
Expand All @@ -20,3 +31,42 @@ jobs:

- name: Run tests
run: ./gradlew test

- name: Has to be published?
id: is-release
if: startsWith(github.ref, 'refs/tags/v')
run: |
version="$GITHUB_REF_NAME"
version_number="${version:1}"
zip="./build/distributions/Decorate.me-${version_number}.zip"
echo "New version $version_number has to be published"
echo "ZIP_PATH=$zip" >> $GITHUB_OUTPUT
echo "VERSION_NUMBER=$version_number" >> $GITHUB_OUTPUT

- name: Assembles a plugin and prepares ZIP archive for deployment
if: startsWith(github.ref, 'refs/tags/v')
run: ./gradlew buildPlugin

- name: Check version
if: startsWith(github.ref, 'refs/tags/v')
run: |
if [ ! -f "${{steps.is-release.outputs.ZIP_PATH}}" ]; then
echo "Error: Wrong release version! Check if your tag matches with an actual version in build.gradle.kts"
echo "provided tag's version: ${{ steps.is-release.outputs.VERSION_NUMBER }}"
echo "${{ steps.is-release.outputs.ZIP_PATH }} expected to be generated"
echo "but actual was:"
ls ./build/distributions
exit 1
fi

- name: Publish GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.is-release.outputs.ZIP_PATH }}

- name: Publish Plugin to JetBrains Marketplace
if: startsWith(github.ref, 'refs/tags/v')
run: ./gradlew publishPlugin