Skip to content

Instantly share code, notes, and snippets.

@mlocati
Last active May 13, 2023 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mlocati/13ee3421ada65e97e664366971edec39 to your computer and use it in GitHub Desktop.
Save mlocati/13ee3421ada65e97e664366971edec39 to your computer and use it in GitHub Desktop.
Attach concrete5/ConcreteCMS package archive to releases
name: Attach release asset
on:
release:
types:
- created
jobs:
attach_release_asset:
name: Attach release asset
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '5.5'
tools: composer:v1
coverage: none
- name: Checkout
uses: actions/checkout@v2
- name: Create release asset
run: ./.github/workflows/create-release-asset.sh
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./YOUR_PACKAGE_HANDLE.zip
asset_name: YOUR_PACKAGE_HANDLE.zip
asset_content_type: application/zip
#!/bin/sh
set -o errexit
set -o nounset
printf -- '- cleanup... '
rm -rf ./tmp
mkdir ./tmp
echo 'done.'
printf -- '- determining package handle... '
PACKAGE_HANDLE=$(cat controller.php | grep '$pkgHandle' | tr '"' "'" | cut -d"'" -f2)
if test -z "$PACKAGE_HANDLE"; then
echo 'FAILED!' >&2
exit 1
fi
printf -- 'done (%s).\n' "$PACKAGE_HANDLE"
printf -- '- exporting... '
git archive --format=tar --prefix="$PACKAGE_HANDLE/" HEAD | tar -x --directory=./tmp
echo 'done.'
printf -- '- downloading composerpkg... '
curl -sSLf -o ./tmp/composerpkg https://raw.githubusercontent.com/concrete5/cli/master/composerpkg
chmod +x ./tmp/composerpkg
echo 'done.'
printf -- '- patching composer.json... '
sed -i 's/"require-dev"/"require-dev-disabled"/' "./tmp/$PACKAGE_HANDLE/composer.json"
echo 'done.'
printf -- '- installing composer dependencies:\n'
./tmp/composerpkg install --no-interaction --working-dir="./tmp/$PACKAGE_HANDLE" --no-dev --no-suggest --prefer-dist --optimize-autoloader 2>&1 | sed 's/^/ /'
printf -- '- remove useless files... '
rm "./tmp/$PACKAGE_HANDLE/composer.json"
echo 'done.'
printf -- '- creating asset... '
cd ./tmp
zip -rqX "./$PACKAGE_HANDLE.zip" "./$PACKAGE_HANDLE"
cd ..
echo 'done.'
printf -- '- final operations... '
mv "./tmp/$PACKAGE_HANDLE.zip" .
rm -rf ./tmp
echo 'done.'
@mlocati
Copy link
Author

mlocati commented Aug 6, 2021

Instructions

  1. Save the attach-release-asset.yml file to the folder .github/workflows
  2. Edit the attach-release-asset.yml
    1. replace php-version: '5.5' by specifying the minimum PHP version for your package
    2. replace YOUR_PACKAGE_HANDLE with the handle of the package
  3. Save the create-release-asset.sh file to the folder .github/workflows and make it executable

Usage

Simply create a GitHub release: the action will automatically attach to it a zip archive containing the package ready to be installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment