Skip to content

Update dependencies #281

Update dependencies

Update dependencies #281

Workflow file for this run

name: Scala CI
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'oracle'
- name: Get commit timestamp
uses: actions/github-script@v6
id: commit-timestamp
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commit_details = await github.rest.git.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha
});
return Date.parse(commit_details.data.author.date) / 1000;
- name: Cache coursier cache
uses: actions/cache@v3
with:
path: ~/.cache/coursier
key: ${{ runner.os }}-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/**/*.scala') }}
restore-keys: |
${{ runner.os }}-coursier-cache-${{ hashFiles('**/*.sbt') }}
${{ runner.os }}-coursier-cache
- name: Cache sbt
uses: actions/cache@v3
with:
path: ~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/**/*.scala') }}
restore-keys: |
${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}
${{ runner.os }}-sbt
- name: Test
run: sbt test
- name: Package
run: sbt packageArtifact packageArtifactZip "generateUpdatePluginsXml https://github.com/$GITHUB_REPOSITORY/releases/download/nightly/"
env:
VERSION_SUFFIX: .${{ steps.commit-timestamp.outputs.result }}
- name: IntelliJ Platform Plugin Verifier
uses: ChrisCarini/[email protected]
with:
plugin-location: 'target/RubyRefactorings-*.zip'
failure-levels: |
COMPATIBILITY_WARNINGS
COMPATIBILITY_PROBLEMS
DEPRECATED_API_USAGES
PLUGIN_STRUCTURE_WARNINGS
MISSING_DEPENDENCIES
INVALID_PLUGIN
NOT_DYNAMIC
ide-versions: |
ideaIU:2022.3
ideaIU:LATEST-EAP-SNAPSHOT
- name: Publish nightly release
if: github.ref == 'refs/heads/main'
uses: actions/github-script@v6
id: publish-nightly-release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs");
// Get current nightly release
const currentNightlyRelease = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: 'nightly',
});
// Remove current assets
for (const asset of currentNightlyRelease.data.assets) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id,
});
}
// Upload updated assets
const assetsToUpload = fs.readdirSync('target/')
.filter(relativePath => relativePath.endsWith('.zip') || relativePath.endsWith('.xml'));
for (const assetName of assetsToUpload) {
const assetPath = `target/${assetName}`
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: currentNightlyRelease.data.id,
name: assetName,
headers: {
'content-type': assetPath.endsWith('.xml') ? 'text/xml' : 'application/zip',
'content-length': fs.statSync(assetPath).size,
},
data: fs.readFileSync(assetPath),
})
}
- name: Tag latest commit as nightly and cleanup
if: github.ref == 'refs/heads/main'
run: |
git tag -f nightly
git push "https://${GITHUB_ACTOR}:${REPO_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" --tags -f
rm target/*.zip
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Package for release and tag commit
if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, '[Release]')
id: package-for-release
run: |
sbt packageArtifactZip
PLUGIN_VERSION=$(ls target | grep "RubyRefactorings-.*.zip" | grep -oE [0-9]+\.[0-9]+\.[0-9]+)
git tag -f v$PLUGIN_VERSION
git push "https://${GITHUB_ACTOR}:${REPO_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" --tags
sbt "generateUpdatePluginsXml https://github.com/$GITHUB_REPOSITORY/releases/download/v$PLUGIN_VERSION/"
printf "v$PLUGIN_VERSION" > releaseTag
- name: Create Github release
if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, '[Release]')
uses: actions/github-script@v6
id: create-github-release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs");
// Create new release
const releaseTag = fs.readFileSync('releaseTag', 'utf8')
const newRelease = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: releaseTag,
name: `Release ${releaseTag}`,
body: fs.readFileSync('CHANGELOG.md', 'utf8'),
});
// Upload assets
const assetsToUpload = fs.readdirSync('target/')
.filter(relativePath => relativePath.endsWith('.zip') || relativePath.endsWith('.xml'));
for (const assetName of assetsToUpload) {
const assetPath = `target/${assetName}`
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: newRelease.data.id,
name: assetName,
headers: {
'content-type': assetPath.endsWith('.xml') ? 'text/xml' : 'application/zip',
'content-length': fs.statSync(assetPath).size,
},
data: fs.readFileSync(assetPath),
})
}
- name: Publish release
if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, '[Release]')
run: sbt publishPlugin
env:
IJ_PLUGIN_REPO_TOKEN: ${{ secrets.IJ_PLUGIN_REPO_TOKEN }}