Skip to content

Commit 847e1b4

Browse files
committed
Update create-release with some extra options
This commit introduces some new options to the create-release workflow that can be used to control the exact paths in the output artifact. The options are: * `flatten` - Strip out the top level directory that the assemble-release action adds within the zip. * `version-file` - Specify a version file to be uploaded to the release alongside the existing release artifact.
1 parent 8da2de0 commit 847e1b4

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

.github/actions/assemble-release/action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ inputs:
1717
description: Output artifact name used in the upload-artifact action WITHOUT ".zip" extension. a zip file with this name will be created in the github workspace so that it can be immediately consumed by other actions in the workflow without having to download the artifact.
1818
default: ${{ github.event.repository.name || 'release'}}
1919

20+
flatten:
21+
description: If `true`, the zip is built with the artifact files at the root instead of nested under a top-level `output-file-name` directory. Use this when consumers expect to extract the archive directly into a target directory (e.g. `GameData/`, `LICENSE`, etc. at the root of the zip).
22+
default: "false"
23+
2024
working-directory:
2125
default: ${{ github.workspace }}
2226
description: The working directory to run in
@@ -63,6 +67,10 @@ runs:
6367
shell: bash
6468
working-directory: ${{ env.RELEASE_STAGING }}
6569
run: |
66-
zip -r ${{ inputs.output-file-name }}.zip ${{ inputs.output-file-name}}
70+
if [ '${{ inputs.flatten }}' = 'true' ]; then
71+
(cd '${{ inputs.output-file-name }}' && zip -9 -r '../${{ inputs.output-file-name }}.zip' .)
72+
else
73+
zip -9 -r '${{ inputs.output-file-name }}.zip' '${{ inputs.output-file-name }}'
74+
fi
6775
echo 'artifact-zip-path=${{ env.RELEASE_STAGING }}/${{ inputs.output-file-name }}.zip' >> $GITHUB_OUTPUT
6876
echo 'artifact-dir-path=${{ env.RELEASE_STAGING }}/${{ inputs.output-file-name}}' >> $GITHUB_OUTPUT

.github/workflows/create-release.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ on:
1818
artifacts:
1919
type: string
2020
default: GameData LICENSE* README* CHANGELOG*
21+
flatten:
22+
type: boolean
23+
default: false
24+
description: >
25+
If true, the release zip is built with the artifact files at the root
26+
instead of nested under a top-level directory. Forwarded to the
27+
assemble-release action.
28+
version-file:
29+
type: string
30+
description: >
31+
Path to a KSP-AVC `.version` file (relative to the repository root).
32+
If set, the file is attached to the github release as a separate
33+
asset alongside the assembled zip, so tools like CKAN's NetKAN can
34+
read it without downloading the full archive.
2135
ksp-zip-url:
2236
type: string
2337
default: https://github.com/KSPModdingLibs/KSPLibs/raw/main/KSP-1.12.5.zip
@@ -105,10 +119,15 @@ jobs:
105119
with:
106120
artifacts: ${{ inputs.artifacts }}
107121
output-file-name: ${{ github.event.repository.name }}-${{ env.VERSION_STRING }}
122+
flatten: ${{ inputs.flatten }}
108123

109124
- name: create-release
110125
env:
111126
GH_TOKEN: ${{ github.token }}
127+
ARTIFACT_ZIP: ${{ steps.assemble-release.outputs.artifact-zip-path }}
128+
VERSION_FILE: ${{ inputs.version-file }}
112129
run: |
113130
git push
114-
gh release create "$VERSION_STRING" --draft --target ${{ github.ref_name }} --title "$VERSION_STRING" "${{ steps.assemble-release.outputs.artifact-zip-path }}" --notes-file "$RELEASE_NOTES_FILE"
131+
assets=("$ARTIFACT_ZIP")
132+
[ -n "$VERSION_FILE" ] && assets+=("$VERSION_FILE")
133+
gh release create "$VERSION_STRING" --draft --target ${{ github.ref_name }} --title "$VERSION_STRING" --notes-file "$RELEASE_NOTES_FILE" "${assets[@]}"

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this project will be documented in this file
44

5+
## Unreleased
6+
7+
### Workflows
8+
9+
- `assemble-release` action: zip output now uses maximum compression (`-9`).
10+
- `assemble-release` action: new `flatten` input. When `true`, the artifact files are placed at the root of the zip instead of nested under a top-level `output-file-name` directory.
11+
- `create-release` workflow: forwards a new `flatten` input to `assemble-release`.
12+
- `create-release` workflow: new `version-file` input — path to a KSP-AVC `.version` file that should be attached to the github release as a separate asset alongside the assembled zip (for tools like CKAN's NetKAN).
13+
14+
515
## 1.1.1 - 2025-12-01
616

717
### Msbuild

0 commit comments

Comments
 (0)