Skip to content

Commit

Permalink
Merge pull request ballerina-platform#73 from NipunaRanasinghe/workflows
Browse files Browse the repository at this point in the history
Add workflows for the swan lake plugin
  • Loading branch information
NipunaRanasinghe authored Jun 10, 2024
2 parents 1b15224 + 2d79226 commit 4c1de53
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/daily-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Daily Build

on:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight UTC

jobs:
build-and-test:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.head_ref }}-ubuntu-build
cancel-in-progress: true

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Run Build
run: ./gradlew build

- name: Create Plugin Zip
run: ./gradlew buildPlugin

- name: Archive Plugin Zip
uses: actions/upload-artifact@v3
with:
name: plugin-distribution
path: build/distributions/*.zip
27 changes: 27 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pull Request

on:
pull_request:
branches:
- master
- 2.[0-9]+.x

jobs:
pr-check:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event.pull_request.head.ref }}-pr-check
cancel-in-progress: true

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Run Tests
run: ./gradlew build test
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release Plugin

on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
if: github.repository_owner == 'ballerina-platform'
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'


- name: Run Gradle Build
run: |
./gradlew build
- name: Get Release Version
run: echo "VERSION=$((grep -w 'pluginVersion' | cut -d= -f2) < gradle.properties | rev | cut -d- -f2 | rev)" >> $GITHUB_ENV

- name: Checkout to Release Branch
run: |
echo "Version: ${VERSION}"
git checkout -b release-${VERSION}
- name: Perform Release
run: |
./gradlew clean release -Prelease.useAutomaticVersion=true
- name: Sign Plugin
run: ./gradlew signPlugin
env:
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}

- name: Publish Plugin
run: ./gradlew publishPlugin
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}

- name: GitHub Release and Release Sync PR
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
gh release create $VERSION --title "$VERSION"
gh pr create --base ${GITHUB_REF##*/} --title "[Automated] Sync ${GITHUB_REF##*/} after $VERSION release" --body "Sync ${GITHUB_REF##*/} after $VERSION release"
56 changes: 56 additions & 0 deletions .github/workflows/verification-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Plugin Verification Build
description: |
This workflow is used to verify the plugin against different versions of IntelliJ IDEA.
It reads the minimum and maximum supported versions from the `gradle.properties` file
and runs the plugin against each version in the range.
on:
push:
branches:
- master
- 2.[0-9]+.x
workflow_dispatch:

jobs:
read-versions:
runs-on: ubuntu-latest
outputs:
min-idea-version: ${{ steps.set-env.outputs.min-idea-version }}
max-idea-version: ${{ steps.set-env.outputs.max-idea-version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Read IntelliJ IDEA versions
id: set-env
run: |
sinceBuild=$(grep "^sinceBuild" gradle.properties | cut -d'=' -f2)
untilBuild=$(grep "^untilBuild" gradle.properties | cut -d'=' -f2)
echo "min-idea-version=${sinceBuild}" >> $GITHUB_ENV
echo "max-idea-version=${untilBuild}" >> $GITHUB_ENV
echo "::set-output name=min-idea-version::${sinceBuild}"
echo "::set-output name=max-idea-version::${untilBuild}"
verify-plugin:
needs: read-versions
runs-on: ubuntu-latest
strategy:
matrix:
idea-version: [ ${ { needs.read-versions.outputs.min-idea-version } }, ${ { needs.read-versions.outputs.max-idea-version } } ]

concurrency:
group: ${{ github.head_ref }}-ubuntu-verify
cancel-in-progress: true

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Verify against IDEA ${{ matrix.idea-version }}
run: ./gradlew runIde -PideaVersion=${{ matrix.idea-version }}
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
id 'java'
id 'checkstyle'
id 'com.github.spotbugs'
id 'net.researchgate.release'
}

repositories {
Expand Down Expand Up @@ -108,6 +109,18 @@ checkstyleTest {
classpath = sourceSets.test.compileClasspath
}

release {
buildTasks = ['build']
failOnSnapshotDependencies = true
versionPropertyFile = 'gradle.properties'
versionProperties = ['version']
tagTemplate = '${version}'
git {
requireBranch = 'release-${moduleVersion}'
pushToRemote = 'origin'
}
}

build.dependsOn check
runIde.dependsOn check
buildPlugin.dependsOn check
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ lsp4IntellijVersion=0.96.2
checkStyleVersion=8.36
downloadPluginVersion=5.4.0
spotbugsPluginVersion=5.0.14
releasePluginVersion=2.8.0

# IntelliJ IDE Configuration
ideaVersion=2024.1
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pluginManagement {
id "org.jetbrains.intellij" version "${intellijPluginVersion}"
id "de.undercouch.download" version "${downloadPluginVersion}"
id "com.github.spotbugs" version "${spotbugsPluginVersion}"
id "net.researchgate.release" version "${releasePluginVersion}"
}

repositories {
Expand Down

0 comments on commit 4c1de53

Please sign in to comment.