Skip to content

build: migrate from jenkins to github maven repo / release version #284

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

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 70 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we now have a manual release trigger.

release_version:
description: 'Release version'
required: true
type: string

jobs:
build:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -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 "[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 }}
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'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
============
Expand Down
Loading