Skip to content
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

[toolbox] Build in CI #487

Merged
merged 1 commit into from
Sep 24, 2024
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
90 changes: 23 additions & 67 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,68 +66,22 @@ jobs:
java-version: 17
cache: gradle

# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo "::set-output name=version::$VERSION"
echo "::set-output name=name::$NAME"
echo "::set-output name=changelog::$CHANGELOG"
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier

# Run plugin build
- name: Run Build
run: ./gradlew clean buildPlugin --info

# until https://github.com/JetBrains/gradle-intellij-plugin/issues/1027 is solved

# # Cache Plugin Verifier IDEs
# - name: Setup Plugin Verifier IDEs Cache
# uses: actions/[email protected]
# with:
# path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
# key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
#
# # Run Verify Plugin task and IntelliJ Plugin Verifier tool
# - name: Run Plugin Verification tasks
# run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
#
# # Collect Plugin Verifier Result
# - name: Collect Plugin Verifier Result
# if: ${{ always() }}
# uses: actions/upload-artifact@v4
# with:
# name: pluginVerifier-result
# path: ${{ github.workspace }}/build/reports/pluginVerifier
run: ./gradlew clean build --info

# Run Qodana inspections
- name: Qodana - Code Inspection
uses: JetBrains/[email protected]

# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
id: artifact
shell: bash
run: |
cd ${{ github.workspace }}/build/distributions
FILENAME=`ls *.zip`
unzip "$FILENAME" -d content
echo "::set-output name=filename::${FILENAME:0:-4}"
# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/content/*/*
# TODO: Need a modified copyPlugin task or something like that to copy all
# the required jar files.
#- name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: ${{ steps.artifact.outputs.filename }}
# path: ./build/distributions/content/*/*

# Prepare a draft release for GitHub Releases page for the manual verification
# If accepted and published, release workflow would be triggered
Expand All @@ -142,24 +96,26 @@ jobs:
- name: Fetch Sources
uses: actions/[email protected]

# TODO: If we keep the two plugins in the same repository, we need a way
# to differentiate the tags and releases.
# Remove old release drafts by using the curl request for the available releases with draft flag
- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/releases \
--jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
run: echo "Not implemented" ; exit 1 #|
#gh api repos/{owner}/{repo}/releases \
# --jq '.[] | select(.draft == true) | .id' \
# | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
# Create new release draft - which is not publicly visible and requires manual acceptance
- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ needs.build.outputs.version }} \
--draft \
--target ${GITHUB_REF_NAME} \
--title "v${{ needs.build.outputs.version }}" \
--notes "$(cat << 'EOM'
${{ needs.build.outputs.changelog }}
EOM
)"
run: echo "Not implemented" ; exit 1 #|
#gh release create v${{ needs.build.outputs.version }} \
# --draft \
# --target ${GITHUB_REF_NAME} \
# --title "v${{ needs.build.outputs.version }}" \
# --notes "$(cat << 'EOM'
#${{ needs.build.outputs.changelog }}
#EOM
#)"
53 changes: 5 additions & 48 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,63 +27,20 @@ jobs:
java-version: 17
cache: gradle

# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
${{ github.event.release.body }}
EOM
)"

CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"

echo "::set-output name=changelog::$CHANGELOG"

# Update Unreleased section with the current release note
- name: Patch Changelog
if: ${{ steps.properties.outputs.changelog != '' }}
env:
CHANGELOG: ${{ steps.properties.outputs.changelog }}
run: |
./gradlew patchChangelog --release-note="$CHANGELOG"

# Publish the plugin to the Marketplace
# TODO@JB: Not sure if Toolbox will go to the same marketplace.
- name: Publish Plugin
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 --info
run: echo "Not implemented" ; exit 1 #./gradlew publishPlugin --info

# Upload artifact as a release asset
# TODO: Need a modified copyPlugin task or something like that to copy all
# the required jar files.
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*

# Create pull request
- name: Create Pull Request
if: ${{ steps.properties.outputs.changelog != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.event.release.tag_name }}"
BRANCH="changelog-update-$VERSION"

git config user.email "[email protected]"
git config user.name "GitHub Action"

git checkout -b $BRANCH
git commit -am "Changelog update - $VERSION"
git push --set-upstream origin $BRANCH

gh pr create \
--title "Changelog update - \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--base main \
--head $BRANCH
run: echo "Not implemented" ; exit 1 #gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
Loading