blob: b21eb0ec4e9553d12921d5fe6a0fada0df9555be [file]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Nightly workflow for building and publishing plugin versions to the nightly channel.
#
# Runs on a daily schedule (2:00 AM UTC) and checks if there are new commits
# since the last nightly tag. If changes are detected (or triggered manually),
# it builds the plugin and publishes to the JetBrains Marketplace nightly channel.
name: Nightly
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
jobs:
# Check if there are new commits since the last nightly tag
check-changes:
name: Check for changes
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.check.outputs.has_changes }}
permissions:
contents: read
steps:
- name: Fetch Sources
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Check for new commits
id: check
run: |
# Find the latest nightly tag
LATEST_TAG=$(git tag --list 'v*-nightly.*' --sort=-version:refname | head -1)
if [ -z "$LATEST_TAG" ]; then
# No previous nightly tag exists — first run, always build
echo "No previous nightly tag found, will build"
echo "has_changes=true" >> $GITHUB_OUTPUT
else
# Count commits between last nightly tag and HEAD
COUNT=$(git rev-list "${LATEST_TAG}..HEAD" --count 2>/dev/null || echo "999")
echo "Commits since ${LATEST_TAG}: ${COUNT}"
if [ "$COUNT" -gt 0 ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
fi
# Build and publish nightly build
nightly-release:
name: Nightly release
needs: [ check-changes ]
if: needs.check-changes.outputs.has_changes == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Check out the current repository
- name: Fetch Sources
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
# Set up Java environment
- name: Setup Java
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5
with:
distribution: zulu
java-version: 21
# Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
with:
cache-cleanup: always
# Generate version for nightly build
- name: Generate Version
id: version
run: |
PLUGIN_VERSION=$(grep "pluginVersion" gradle.properties | cut -d '=' -f2 | tr -d ' ')
BRANCH=$(echo "$PLUGIN_VERSION" | cut -d '.' -f1)
BUILD=$(echo "$PLUGIN_VERSION" | cut -d '.' -f2)
# Check for existing nightly tags with the same middle segment
LATEST_NIGHTLY=$(git tag --list "v${BRANCH}.${BUILD}-nightly.*" --sort=-version:refname | head -1)
if [ -n "$LATEST_NIGHTLY" ]; then
NIGHTLY_NUM=$(echo "$LATEST_NIGHTLY" | sed 's/.*-nightly\.\([0-9]*\)/\1/')
NIGHTLY_NUM=$((NIGHTLY_NUM + 1))
else
NIGHTLY_NUM=1
fi
sed -i "s/pluginVersion = .*/pluginVersion = ${BRANCH}.${BUILD}-nightly.${NIGHTLY_NUM}/" gradle.properties
# Get final version and changelog
PROPERTIES="$(./gradlew properties --no-configuration-cache --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
CHANGELOG="$(./gradlew getChangelog --no-configuration-cache --unreleased --no-header --console=plain -q)"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Build plugin with new version
- name: Build Plugin
run: ./gradlew buildPlugin --no-configuration-cache
# Publish to JetBrains Marketplace nightly channel
- name: Publish Plugin to Marketplace (Nightly)
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
run: ./gradlew publishPlugin --no-configuration-cache
# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
id: artifact
shell: bash
run: |
cd ${{ github.workspace }}/build/distributions
FILENAME=$(ls *-signed.zip 2>/dev/null || ls *.zip | head -1)
unzip "$FILENAME" -d content
# Use the version-based filename for artifact
echo "filename=struts-intellij-plugin-v${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/content/*/*
# Tag the nightly build for version tracking
- name: Create Nightly Tag
run: |
git tag "v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"