Workaround for slow EDT warning on IntelliJ 2024.1 EAP #296
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitHub Actions Workflow created for handling the release process based on the draft release prepared | |
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided. | |
name: Release | |
on: | |
release: | |
types: [prereleased, released] | |
jobs: | |
# Prepare and publish the plugin to the Marketplace repository | |
release: | |
name: Publish Plugin | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.properties.outputs.version }} | |
steps: | |
# Setup Java 11 environment for the next steps | |
- name: Setup Java | |
uses: actions/[email protected] | |
with: | |
java-version: 17 | |
distribution: 'corretto' | |
# Check out current repository | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
# Cache Gradle Dependencies | |
- name: Setup Gradle Dependencies Cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }} | |
# Cache Gradle Wrapper | |
- name: Setup Gradle Wrapper Cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} | |
# Set environment variables | |
- name: Export Properties | |
id: properties | |
shell: bash | |
run: | | |
VERSION="$(perl -0777 -ne '/=== ([.0-9]*)/s && print $1; ' CHANGELOG.adoc)" | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
# Publish the plugin to the Marketplace | |
- name: Publish Plugin | |
env: | |
PRE_RELEASE: ${{ github.event.release.prerelease }} | |
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} | |
run: ./gradlew publishPlugin --stacktrace | |
# add new release to Sentry's release tab | |
# if we wouldn't do this here, Sentry will know about a new release only after the first error being reported | |
# as a release might go without errors for some time, the "fixed in next release" might be updated only too late | |
# https://github.com/marketplace/actions/sentry-release | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: production | |
version: ${{ github.ref }} | |
cleanup: | |
name: Cleanup old builds | |
# avoid 403 error with message "Resource not accessible by integration" (seen with dependabot) | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cleanup old runs | |
uses: actions/github-script@v7 | |
# language=js | |
with: | |
script: | | |
const days_to_expiration = 30; | |
const ms_in_day = 86400000; | |
const now = Date.now(); | |
let response = await github.rest.actions.listWorkflowRuns({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
per_page: 30, | |
workflow_id: 'release.yml' | |
}); | |
// traverse from the end to delete from the end to not get confused when deleting items | |
let page = Math.ceil(response.data.total_count / 30) | |
while (page > 1) { | |
response = await github.rest.actions.listWorkflowRuns({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
page: page, | |
workflow_id: 'release.yml' | |
}); | |
for (const run of response.data.workflow_runs) { | |
const days_old = Math.ceil((now - Date.parse(run.created_at)) / ms_in_day) | |
if (days_old > days_to_expiration) { | |
console.log(`Run id ${run.id} is ${days_old} day old. Deleting...`); | |
await github.rest.actions.deleteWorkflowRun({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: run.id | |
}); | |
} else { | |
console.log(`Run id ${run.id} is ${days_old} day old. Keeping...`); | |
} | |
} | |
-- page | |
} |