diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de2b9f6f..8ab8cdaa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,19 @@ -name: Generate changelog and plugin archive for new release +name: Release +run-name: Release ${{ inputs.release_version }} + +#Only one job at a time +concurrency: release + on: - push: - tags: - - '*' + workflow_dispatch: + inputs: + release_version: + description: 'Release version' + required: true + type: string + jobs: - build: + release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -14,36 +23,72 @@ jobs: java-version: 17 distribution: 'temurin' cache: 'gradle' - - name: Grant execute permission for gradlew - run: chmod +x gradlew + # Setup Gradle + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Build with Gradle run: ./gradlew build - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} + - name: Tag Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.email "action@github.com" + 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 }} + 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 local release repo + - name: Publish Library + run: | + ./gradlew publish + echo "Published $PLUGIN_VERSION." + # Set next SNAPSHOT version + - name: Increment Plugin Version + 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 - name: Simple conventional changelog uses: redhat-developer/simple-conventional-changelog@0a6db1ac3910c2cf66f2e1a530951dba1ece8540 #0.0.12 id: changelog with: token: ${{ secrets.GITHUB_TOKEN }} - current-tag: ${{ steps.get_version.outputs.VERSION }} + current-tag: ${{ inputs.release_version }} types-mapping: 'feat:Features,fix:Bug Fixes,docs:Documentation,refactor:Refactoring,build:Builds,chore:Other' scopes-mapping: 'UI:UI,Hub:Hub' - - name: Create Release - id: create_release - uses: actions/create-release@v1 + # Create a new GitHub release + - name: Create GitHub Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.get_version.outputs.VERSION }} - release_name: ${{ steps.get_version.outputs.VERSION }} - body: ${{ steps.changelog.outputs.changelog }} - - name: Attach zip to release - uses: actions/upload-release-asset@v1 + run: | + gh release create ${{ inputs.release_version }} \ + --title "${{ inputs.release_version }}" \ + --notes "$(cat << 'EOM' + ${{ steps.changelog.outputs.changelog }} + EOM + )" + - name: Upload Release Asset env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: '${{ github.workspace }}/build/libs/intellij-common-${{ steps.get_version.outputs.VERSION }}.jar' - asset_name: 'intellij-common-${{ steps.get_version.outputs.VERSION }}.jar' - asset_content_type: application/java-archive + run: gh release upload ${{ inputs.release_version }} ./build/libs/*.jar' diff --git a/README.md b/README.md index c7e43cb1..a3bfd6a9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # IntelliJ Common -[release-svg]: https://img.shields.io/nexus/r/com.redhat.devtools.intellij/intellij-common?server=https%3A%2F%2Frepository.jboss.org%2Fnexus +[release-svg]: https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fredhat-developer%2Fintellij-common%2Frepository%2Freleases%2Fcom%2Fredhat%2Fdevtools%2Fintellij%2Fintellij-common%2Fmaven-metadata.xml [nightly-svg]: https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fredhat-developer%2Fintellij-common%2Frepository%2Fsnapshots%2Fcom%2Fredhat%2Fdevtools%2Fintellij%2Fintellij-common%2Fmaven-metadata.xml ![Build status](https://github.com/redhat-developer/intellij-common/actions/workflows/ci.yml/badge.svg) ![Validate against IJ versions](https://github.com/redhat-developer/intellij-common/actions/workflows/IJ.yml/badge.svg) @@ -69,7 +69,7 @@ Example of a lesson ## Release notes -See the change log. +See the change log on the [release tab](https://github.com/redhat-developer/intellij-common/releases). Contributing ============