Skip to content

Commit

Permalink
Fix release publishing
Browse files Browse the repository at this point in the history
Use `release_id` instead of `upload_url`.
Use `data` instead of `file`.
Use a loop.
  • Loading branch information
sbrunner committed Sep 23, 2024
1 parent 0038c54 commit b052e41
Showing 1 changed file with 19 additions and 55 deletions.
74 changes: 19 additions & 55 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,61 +173,25 @@ jobs:
'X-GitHub-Api-Version': '2022-11-28'
}
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
url: release.data.upload_url,
name: "print-servlet-${{ steps.version.outputs.version }}.war",
file: fs.readFileSync("./core/build/libs/print-servlet-${{ steps.version.outputs.version }}.war"),
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'content-type': 'application/java-archive'
},
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
url: release.data.upload_url,
name: "print-cli-${{ steps.version.outputs.version }}.zip",
file: fs.readFileSync("./core/build/distributions/core-${{ steps.version.outputs.version }}.zip"),
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'content-type': 'application/zip'
},
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
url: release.data.upload_url,
name: "print-lib-${{ steps.version.outputs.version }}.jar",
file: fs.readFileSync("./core/build/libs/print-lib-${{ steps.version.outputs.version }}.jar"),
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'content-type': 'application/java-archive'
},
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
url: release.data.upload_url,
name: "print-lib-${{ steps.version.outputs.version }}-sources.jar",
file: fs.readFileSync("./core/build/libs/print-lib-${{ steps.version.outputs.version }}-sources.jar"),
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'content-type': 'application/java-archive'
},
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
url: release.data.upload_url,
name: "print-lib-${{ steps.version.outputs.version }}-javadoc.jar",
file: fs.readFileSync("./core/build/libs/print-lib-${{ steps.version.outputs.version }}-javadoc.jar"),
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'content-type': 'application/java-archive'
},
});
for (const archive of [
{prefix: 'print-servlet-', suffix: '.war', filePrefix: './core/build/libs/print-servlet-', 'mime-type': 'application/java-archive'},
{prefix: 'print-cli-', suffix: '.zip', filePrefix: './core/build/distributions/core-', 'mime-type': 'application/zip'},
{prefix: 'print-lib-', suffix: '.jar', filePrefix: './core/build/libs/print-lib-', 'mime-type': 'application/java-archive'},
{prefix: 'print-lib-', suffix: '-sources.jar', filePrefix: './core/build/libs/print-lib-', 'mime-type': 'application/java-archive'},
{prefix: 'print-lib-', suffix: '-javadoc.jar', filePrefix: './core/build/libs/print-lib-', 'mime-type': 'application/java-archive'},
]) {
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: archive.prefix + '${{ steps.version.outputs.version }}' + archive.suffix,
data: fs.readFileSync(archive.filePrefix + '${{ steps.version.outputs.version }}' + archive.suffix),
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'content-type': archive['mime-type']
},
});
}
if: startsWith(github.ref, 'refs/tags/') && env.HAS_SECRETS == 'HAS_SECRETS'

# Update the documentation
Expand Down

0 comments on commit b052e41

Please sign in to comment.