Skip to content

Commit f60ffb1

Browse files
Update create release (#70)
Co-authored-by: Phantomical <phantom@lynches.ca>
1 parent 566ebad commit f60ffb1

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: "true"
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: true
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
@@ -110,10 +124,15 @@ jobs:
110124
with:
111125
artifacts: ${{ inputs.artifacts }}
112126
output-file-name: ${{ github.event.repository.name }}-${{ env.VERSION_STRING }}
127+
flatten: ${{ inputs.flatten }}
113128

114129
- name: create-release
115130
env:
116131
GH_TOKEN: ${{ github.token }}
132+
ARTIFACT_ZIP: ${{ steps.assemble-release.outputs.artifact-zip-path }}
133+
VERSION_FILE: ${{ inputs.version-file }}
117134
run: |
118135
git push
119-
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"
136+
assets=("$ARTIFACT_ZIP")
137+
[ -n "$VERSION_FILE" ] && assets+=("$VERSION_FILE")
138+
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)