Last active
May 13, 2023 11:22
-
-
Save mlocati/13ee3421ada65e97e664366971edec39 to your computer and use it in GitHub Desktop.
Attach concrete5/ConcreteCMS package archive to releases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions
attach-release-asset.yml
file to the folder.github/workflows
attach-release-asset.yml
php-version: '5.5'
by specifying the minimum PHP version for your packageYOUR_PACKAGE_HANDLE
with the handle of the packagecreate-release-asset.sh
file to the folder.github/workflows
and make it executableUsage
Simply create a GitHub release: the action will automatically attach to it a zip archive containing the package ready to be installed