Skip to content

Commit

Permalink
Publish pre-release jars
Browse files Browse the repository at this point in the history
Pre-release jars are built and published to draft releases
  • Loading branch information
vlsi committed Jan 29, 2023
1 parent b1e3f74 commit 17f89f6
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
57 changes: 56 additions & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,72 @@ jobs:
if: github.repository_owner == 'vlsi'
name: Update Release Draft
runs-on: ubuntu-latest
env:
# Publish pre-release files to a draft release
PUBLISH_SNAPSHOT: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
- name: Update release body draft
uses: release-drafter/release-drafter@v5
id: prepare_release
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout sources
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: actions/checkout@v3
- name: Set up JDK 17
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: actions/setup-java@v3
with:
java-version: 17
distribution: liberica
- name: Build
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: burrunan/gradle-cache-action@v1
with:
job-id: jdk17
arguments: --scan --no-parallel --no-daemon shadowJar
- name: Attach files to release
if: ${{ env.PUBLISH_SNAPSHOT }}
uses: actions/github-script@v6
env:
# https://github.com/release-drafter/release-drafter#action-outputs
RELEASE_ID: ${{ steps.prepare_release.outputs.id }}
with:
# language=JavaScript
script: |
const fs = require('fs');
const {RELEASE_ID} = process.env;
// remove old jar files from the release
const assets = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: RELEASE_ID
});
for (const asset of assets.data) {
if (asset.name.endsWith('-all.jar')) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id
});
}
}
const globber = await glob.create('build/libs/ksar-*-all.jar');
const files = await globber.glob();
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
name: files[0].replace(/^(.*build\/libs\/ksar-)/, "ksar-"),
release_id: RELEASE_ID,
data: fs.readFileSync(files[0])
})
18 changes: 17 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout sources
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -38,6 +39,21 @@ jobs:
script: |
const fs = require('fs');
const {TAG, RELEASE_ID} = process.env;
// remove old jar files from the release
const assets = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: RELEASE_ID
});
for (const asset of assets.data) {
if (asset.name.endsWith('-all.jar')) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id
});
}
}
const version = TAG.substring(1); // remove leading v
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
Expand Down

0 comments on commit 17f89f6

Please sign in to comment.