Skip to content

Commit

Permalink
CI: Switch to a custom zip action
Browse files Browse the repository at this point in the history
This allows us to customize it to our needs, such as
zipping subfolders into separate archives.
The new actions is also simpler as unused features
of the original are stripped.
  • Loading branch information
YuriSizov committed Apr 30, 2024
1 parent a9f65a7 commit d0c430e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.sh]
indent_style = space
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2
3 changes: 1 addition & 2 deletions .github/actions/publish-extension/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ runs:
using: "composite"
steps:
- name: Archive the artifact
uses: thedoctor0/zip-[email protected]
uses: ./.github/actions/zip-folder
with:
type: zip
directory: ${{ inputs.directory }}
path: ${{ inputs.path }}
filename: libgdsion-${{ inputs.platform }}.zip
Expand Down
28 changes: 28 additions & 0 deletions .github/actions/zip-folder/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Zip up a folder
description: Create a zip archive of a folder or folders.

inputs:
filename:
description: Output file name for the archive.
default: ""
path:
description: Base path for archive files.
default: "."
directory:
description: Working directory where the command is called.
default: "."
split:
description: Create a separate archive for each directory in the base path. Folder's name is the file name.
default: false

runs:
using: composite
steps:
- name:
shell: bash
working-directory: ${{ inputs.directory }}
env:
ARCHIVE_OUTPUT_NAME: ${{ inputs.filename }}
ARCHIVE_INCLUDE_PATH: ${{ inputs.path }}
ARCHIVE_SPLIT: ${{ inputs.split && 1 || 0 }}
run: $GITHUB_ACTION_PATH/zip.sh
30 changes: 30 additions & 0 deletions .github/actions/zip-folder/zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#! /bin/bash

# Adapted from https://github.com/TheDoctor0/zip-release.

# Create archive or exit if the command fails
set -eu
printf "\n📦 Creating zip archive...\n"

if [ "$RUNNER_OS" = "Windows" ]; then
if [ "$ARCHIVE_SPLIT" = 1 ]; then
for dir in $ARCHIVE_INCLUDE_PATH/*/ ; do
7z a -tzip "$dir" $ARCHIVE_INCLUDE_PATH/$dir/ || { printf "\n⛔ Unable to create zip archive.\n"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$dir"
done
else
7z a -tzip "$ARCHIVE_OUTPUT_NAME" $ARCHIVE_INCLUDE_PATH || { printf "\n⛔ Unable to create zip archive.\n"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$ARCHIVE_OUTPUT_NAME"
fi
else
if [ "$ARCHIVE_SPLIT" = 1 ]; then
for dir in $ARCHIVE_INCLUDE_PATH/*/ ; do
zip -r "$dir" $ARCHIVE_INCLUDE_PATH/$dir/ || { printf "\n⛔ Unable to create zip archive.\n"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$dir"
done
else
zip -r "$ARCHIVE_OUTPUT_NAME" $ARCHIVE_INCLUDE_PATH || { printf "\n⛔ Unable to create zip archive.\n"; exit 1; }
printf "\n✔ Successfully created %s archive.\n" "$ARCHIVE_OUTPUT_NAME"
fi
fi

2 changes: 1 addition & 1 deletion .github/workflows/example-export-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install Godot ${{ env.GODOT_VERSION }}
uses: chickensoft-games/setup-godot@v1
uses: chickensoft-games/setup-godot@v2
with:
version: ${{ env.GODOT_VERSION }}
use-dotnet: false
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/example-publish-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,27 @@ jobs:
merge-multiple: true

- name: Archive example project sources
uses: thedoctor0/zip-[email protected]
uses: ./.github/actions/zip-folder
with:
type: zip
directory: example
filename: example-project-source.zip

- name: Download example project artifacts
uses: actions/download-artifact@v4
with:
path: example/export
pattern: example-project-*

- name: Archive example project exports
uses: ./.github/actions/zip-folder
with:
directory: example/export
split: true

- name: Print folder contents
shell: bash
run: dir -la ./example/export

- name: Update the rolling release with the example project
shell: bash
env:
Expand Down

0 comments on commit d0c430e

Please sign in to comment.