Skip to content

Commit d187672

Browse files
authored
chore(ci): migrate jenkins to github workflow (#208)
Signed-off-by: Ruben Romero Montes <[email protected]>
1 parent 8f57823 commit d187672

File tree

3 files changed

+117
-133
lines changed

3 files changed

+117
-133
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Publish to JetBrains Marketplace
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Version to publish (e.g., 1.1.0)'
7+
required: true
8+
type: string
9+
channel:
10+
description: 'Marketplace channel (stable, nightly)'
11+
required: true
12+
type: string
13+
default: 'stable'
14+
release:
15+
types: [published]
16+
schedule:
17+
# Run every day at 2 AM UTC to publish nightly builds
18+
- cron: '0 2 * * *'
19+
push:
20+
branches: [ main ]
21+
22+
jobs:
23+
publish-marketplace:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: 17
33+
distribution: 'temurin'
34+
cache: 'gradle'
35+
36+
- name: Grant execute permission for gradlew
37+
run: chmod +x gradlew
38+
39+
- name: Determine version and channel
40+
id: version_info
41+
run: |
42+
if [ "${{ github.event.inputs.version }}" != "" ]; then
43+
# Manual trigger with specific inputs
44+
VERSION="${{ github.event.inputs.version }}"
45+
CHANNEL="${{ github.event.inputs.channel }}"
46+
elif [ "${{ github.event_name }}" == "release" ]; then
47+
# Release event - publish to stable channel
48+
VERSION="${GITHUB_REF#refs/tags/}"
49+
CHANNEL="stable"
50+
elif [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.event_name }}" == "push" ]; then
51+
# Scheduled run or push to main - publish to nightly channel
52+
# Get current version from gradle.properties and append timestamp
53+
BASE_VERSION=$(grep 'projectVersion=' gradle.properties | cut -d'=' -f2)
54+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
55+
VERSION="${BASE_VERSION}-nightly.${TIMESTAMP}"
56+
CHANNEL="nightly"
57+
else
58+
echo "Unknown trigger: ${{ github.event_name }}"
59+
exit 1
60+
fi
61+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
62+
echo "CHANNEL=$CHANNEL" >> $GITHUB_OUTPUT
63+
echo "Publishing version $VERSION to $CHANNEL channel"
64+
65+
- name: Build or download based on trigger
66+
if: github.event_name == 'schedule' || github.event_name == 'push'
67+
run: |
68+
# For nightly builds, we need to build from source
69+
echo "Building nightly version from source..."
70+
./gradlew buildPlugin -Pgpr.username=${{ github.actor }} -Pgpr.token=${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Download from release
73+
if: github.event_name == 'release'
74+
run: |
75+
# Download the ZIP file from the GitHub release
76+
RELEASE_VERSION="${{ steps.version_info.outputs.VERSION }}"
77+
ZIP_URL="https://github.com/${{ github.repository }}/releases/download/${RELEASE_VERSION}/Dependency-Analytics-${RELEASE_VERSION}.zip"
78+
echo "Downloading from: $ZIP_URL"
79+
mkdir -p build/distributions
80+
curl -L -o "build/distributions/intellij-dependency-analytics-${RELEASE_VERSION}.zip" "$ZIP_URL"
81+
82+
- name: Verify ZIP file exists
83+
run: |
84+
ls -la build/distributions/
85+
# For nightly builds, the filename might be different, so find any ZIP file
86+
if [ "${{ steps.version_info.outputs.CHANNEL }}" == "nightly" ]; then
87+
ZIP_COUNT=$(find build/distributions -name "*.zip" | wc -l)
88+
if [ "$ZIP_COUNT" -eq 0 ]; then
89+
echo "Error: No ZIP files found for nightly build!"
90+
exit 1
91+
fi
92+
# Rename the first ZIP file to match our expected naming convention
93+
FIRST_ZIP=$(find build/distributions -name "*.zip" | head -1)
94+
mv "$FIRST_ZIP" "build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip"
95+
else
96+
# For stable releases, expect the exact filename
97+
if [ ! -f "build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip" ]; then
98+
echo "Error: ZIP file not found!"
99+
exit 1
100+
fi
101+
fi
102+
echo "✅ ZIP file verified: build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip"
103+
104+
- name: Publish to JetBrains Marketplace
105+
run: >
106+
./gradlew publishPlugin
107+
-PjetBrainsToken=${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
108+
-PprojectVersion=${{ steps.version_info.outputs.VERSION }}
109+
-PjetBrainsChannel=${{ steps.version_info.outputs.CHANNEL }}
110+
-Pgpr.username=${{ github.actor }}
111+
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Publish success notification
114+
if: success()
115+
run: |
116+
echo "✅ Successfully published version ${{ steps.version_info.outputs.VERSION }} to ${{ steps.version_info.outputs.CHANNEL }} channel"
117+
echo "📦 ZIP file: build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip"

Jenkinsfile

Lines changed: 0 additions & 70 deletions
This file was deleted.

jenkins-job-config.xml

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)