auto publish GitHub release when new tag pushed. #23
Workflow file for this run
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: CI | |
on: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
ci: | |
name: test | |
runs-on: ubuntu-latest | |
env: | |
PUBLISH_TOKEN: ${{ secrets.PUBLISH }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Build plugin | |
run: ./gradlew build | |
- 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 }} | |