diff --git a/.github/workflows/publish-marketplace.yml b/.github/workflows/publish-marketplace.yml new file mode 100644 index 00000000..0bfdfcfb --- /dev/null +++ b/.github/workflows/publish-marketplace.yml @@ -0,0 +1,117 @@ +name: Publish to JetBrains Marketplace +on: + workflow_dispatch: + inputs: + version: + description: 'Version to publish (e.g., 1.1.0)' + required: true + type: string + channel: + description: 'Marketplace channel (stable, nightly)' + required: true + type: string + default: 'stable' + release: + types: [published] + schedule: + # Run every day at 2 AM UTC to publish nightly builds + - cron: '0 2 * * *' + push: + branches: [ main ] + +jobs: + publish-marketplace: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: 'gradle' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Determine version and channel + id: version_info + run: | + if [ "${{ github.event.inputs.version }}" != "" ]; then + # Manual trigger with specific inputs + VERSION="${{ github.event.inputs.version }}" + CHANNEL="${{ github.event.inputs.channel }}" + elif [ "${{ github.event_name }}" == "release" ]; then + # Release event - publish to stable channel + VERSION="${GITHUB_REF#refs/tags/}" + CHANNEL="stable" + elif [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.event_name }}" == "push" ]; then + # Scheduled run or push to main - publish to nightly channel + # Get current version from gradle.properties and append timestamp + BASE_VERSION=$(grep 'projectVersion=' gradle.properties | cut -d'=' -f2) + TIMESTAMP=$(date +%Y%m%d-%H%M%S) + VERSION="${BASE_VERSION}-nightly.${TIMESTAMP}" + CHANNEL="nightly" + else + echo "Unknown trigger: ${{ github.event_name }}" + exit 1 + fi + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "CHANNEL=$CHANNEL" >> $GITHUB_OUTPUT + echo "Publishing version $VERSION to $CHANNEL channel" + + - name: Build or download based on trigger + if: github.event_name == 'schedule' || github.event_name == 'push' + run: | + # For nightly builds, we need to build from source + echo "Building nightly version from source..." + ./gradlew buildPlugin -Pgpr.username=${{ github.actor }} -Pgpr.token=${{ secrets.GITHUB_TOKEN }} + + - name: Download from release + if: github.event_name == 'release' + run: | + # Download the ZIP file from the GitHub release + RELEASE_VERSION="${{ steps.version_info.outputs.VERSION }}" + ZIP_URL="https://github.com/${{ github.repository }}/releases/download/${RELEASE_VERSION}/Dependency-Analytics-${RELEASE_VERSION}.zip" + echo "Downloading from: $ZIP_URL" + mkdir -p build/distributions + curl -L -o "build/distributions/intellij-dependency-analytics-${RELEASE_VERSION}.zip" "$ZIP_URL" + + - name: Verify ZIP file exists + run: | + ls -la build/distributions/ + # For nightly builds, the filename might be different, so find any ZIP file + if [ "${{ steps.version_info.outputs.CHANNEL }}" == "nightly" ]; then + ZIP_COUNT=$(find build/distributions -name "*.zip" | wc -l) + if [ "$ZIP_COUNT" -eq 0 ]; then + echo "Error: No ZIP files found for nightly build!" + exit 1 + fi + # Rename the first ZIP file to match our expected naming convention + FIRST_ZIP=$(find build/distributions -name "*.zip" | head -1) + mv "$FIRST_ZIP" "build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip" + else + # For stable releases, expect the exact filename + if [ ! -f "build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip" ]; then + echo "Error: ZIP file not found!" + exit 1 + fi + fi + echo "✅ ZIP file verified: build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip" + + - name: Publish to JetBrains Marketplace + run: > + ./gradlew publishPlugin + -PjetBrainsToken=${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} + -PprojectVersion=${{ steps.version_info.outputs.VERSION }} + -PjetBrainsChannel=${{ steps.version_info.outputs.CHANNEL }} + -Pgpr.username=${{ github.actor }} + -Pgpr.token=${{ secrets.GITHUB_TOKEN }} + + - name: Publish success notification + if: success() + run: | + echo "✅ Successfully published version ${{ steps.version_info.outputs.VERSION }} to ${{ steps.version_info.outputs.CHANNEL }} channel" + echo "📦 ZIP file: build/distributions/intellij-dependency-analytics-${{ steps.version_info.outputs.VERSION }}.zip" diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 8e488bfb..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env groovy - -node('rhel7'){ - def recipientList = 'jbosstools-builds@lists.jboss.org' - def javaHome = tool 'openjdk-11' - env.JAVA_HOME = "${javaHome}" - - try { - stage('Checkout repo') { - deleteDir() - git url: 'https://github.com/redhat-developer/intellij-dependency-analytics', - branch: "${sha1}" - } - - def props = readProperties file: 'gradle.properties' - def isSnapshot = props['projectVersion'].contains('-SNAPSHOT') - def version = isSnapshot?props['projectVersion'].replace('-SNAPSHOT', ".${env.BUILD_NUMBER}"):props['projectVersion'] + ".${env.BUILD_NUMBER}" - - // github user and token are required for consuming the exhort-java-api module from GHPR in build-time - withCredentials([[$class: 'StringBinding', credentialsId: 'rhdevelopersci-github-token', variable: 'GITHUB_TOKEN']]) { - stage('Build') { - sh "./gradlew assemble -PprojectVersion=${version} -Pgpr.username=rhdevelopers-ci -Pgpr.token=${GITHUB_TOKEN}" - } - - stage('Package') { - sh "./gradlew buildPlugin -PprojectVersion=${version} -Pgpr.username=rhdevelopers-ci -Pgpr.token=${GITHUB_TOKEN}" - } - } - - if(params.UPLOAD_LOCATION) { - stage('Upload') { - def filesToPush = findFiles(glob: '**/*.zip') - sh "sftp -C ${UPLOAD_LOCATION}/snapshots/intellij-dependency-analytics/ <<< \$'put -p \"${filesToPush[0].path}\"'" - stash name:'zip', includes:filesToPush[0].path - } - } - - if(publishToMarketPlace.equals('true')){ - timeout(time:5, unit:'DAYS') { - input message:'Approve deployment?', submitter: 'jmaury, tfigenbl, zgrinber, vbelouso, xiezhang' - } - - def channel = isSnapshot?"nightly":"stable" - - stage("Publish to Marketplace") { - unstash 'zip' - // github user and token are required for consuming the exhort-java-api module from GHPR in build-time - withCredentials([[$class: 'StringBinding', credentialsId: 'rhdevelopersci-github-token', variable: 'GITHUB_TOKEN']]) { - withCredentials([[$class: 'StringBinding', credentialsId: 'JetBrains marketplace token', variable: 'TOKEN']]) { - sh "./gradlew publishPlugin -PjetBrainsToken=${TOKEN} -PprojectVersion=${version} -PjetBrainsChannel=${channel} -Pgpr.username=rhdevelopers-ci -Pgpr.token=${GITHUB_TOKEN}" - } - } - archive includes:"**.zip" - - if (!isSnapshot) { - stage("Promote the build to stable") { - def zip = findFiles(glob: '**/*.zip') - sh "sftp -C ${UPLOAD_LOCATION}/snapshots/intellij-dependency-analytics/ <<< \$'put -p \"${zip[0].path}\"'" - currentBuild.keepLog = true - currentBuild.description = "${version}" - } - } - } - } - } catch (any) { - currentBuild.result = 'FAILURE' - step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${recipientList}", sendToIndividuals: true]) - throw any - } -} diff --git a/jenkins-job-config.xml b/jenkins-job-config.xml deleted file mode 100644 index ad8ec839..00000000 --- a/jenkins-job-config.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - Intellij Dependency Analytics Build job - false - - - - - H/5 * * * * - false - - - - - - - UPLOAD_LOCATION - tools@filemgmt.jboss.org:/downloads_htdocs/tools/intellij - Base path under which bits are published - - - publishToMarketPlace - false - Publish the build to JetBrains marketplace? - - - sha1 - main - - - - - - https://github.com/redhat-developer/intellij-dependency-analytics/ - - - - - 30 - 5 - -1 - -1 - - - Jenkinsfile - false - - - - https://github.com/redhat-developer/intellij-dependency-analytics - - - - - ${sha1} - - - 2 - false - Default - - - \ No newline at end of file