Create update package #62
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: Create update package | |
on: | |
workflow_dispatch: | |
branches: | |
- "**" | |
push: | |
tags: | |
- "*" | |
schedule: | |
- cron: | |
'0 1 * * *' | |
jobs: | |
create-update-package: | |
env: | |
PACKAGE_PREFIX: 'update' | |
PACKAGE_DELIMITER: _ | |
UPDATE_ASSET_DIR: './update-assets/' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create version | |
run: | | |
TAG=${{ github.ref_name }} | |
echo "VERSION=$(echo ${TAG#v} | cut -d "-" -f 1)" >> $GITHUB_ENV | |
echo "VERSION_TEXT=$(echo ${TAG#v} | cut -d "-" -s -f 2)" >> $GITHUB_ENV | |
shell: bash | |
- name: Clone | |
uses: actions/checkout@v3 | |
- name: Set current date as env variable | |
run: echo "REVISION=$(git log -1 --format="%at" | xargs -I{} date -d @{} +'%Y%m%d%H%M')" >> $GITHUB_ENV | |
- name: Get Composer Cache Directory | |
id: composer-cache | |
run: | | |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Install Composer | |
run: | | |
composer install --no-dev | |
cd recovery/common && composer install --no-dev | |
- name: Download last package | |
run: | | |
mkdir ./output | |
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/shopware5/shopware/releases/latest) | |
LATEST_VERSION_ID=$(echo $LATEST_RELEASE | sed -e 's/.*"id":\([^",]*\).*/\1/') | |
ASSETS=$(curl -L -s -H 'Accept: application/json' https://api.github.com/repos/shopware5/shopware/releases/$LATEST_VERSION_ID/assets) | |
ARTIFACT_URL=$(echo $ASSETS | sed -e 's/.*"browser_download_url": "\([^",]*install[^",]*\)".*/\1/') | |
wget -O install.zip $ARTIFACT_URL | |
unzip install.zip -d ./output/release | |
- name: Replace placeholder | |
run: | | |
sed -i 's=___VERSION___=${{ env.VERSION }}=g' engine/Shopware/Kernel.php | |
sed -i 's=___VERSION_TEXT___=${{ env.VERSION_TEXT }}=g' engine/Shopware/Kernel.php | |
sed -i 's=___REVISION___=${{ env.REVISION }}=g' engine/Shopware/Kernel.php | |
sed -i 's=___VERSION___=${{ env.VERSION }}=g' recovery/install/data/version | |
sed -i 's=___VERSION_TEXT___=${{ env.VERSION_TEXT }}=g' recovery/install/data/version | |
shell: bash | |
- name: Create update asset dir | |
run: | | |
mkdir ${{ env.UPDATE_ASSET_DIR }} | |
- name: Create version file | |
run: | | |
echo "${{ github.ref_name }} ${{ env.REVISION }}" > ${{ env.UPDATE_ASSET_DIR }}version | |
- name: Generate cleanup list | |
run: php ./.github/deleted_files.php --input=$(pwd) > ${{ env.UPDATE_ASSET_DIR }}cleanup.txt | |
- run: cat ${{ env.UPDATE_ASSET_DIR }}cleanup.txt | |
- name: Generate cleanup list | |
run: ./.github/deleted_files_vendor.sh -o $(pwd)/output/release/vendor -n $(pwd)/vendor $(pwd) >> ${{ env.UPDATE_ASSET_DIR }}cleanup.txt | |
- run: cat ${{ env.UPDATE_ASSET_DIR }}cleanup.txt | |
- name: Copy Migrations | |
run: | | |
mv ./_sql/migrations ${{ env.UPDATE_ASSET_DIR }}migrations | |
- name: Dump SQL file with snippets | |
run: | | |
php bin/console sw:snippets:to:sql ${{ env.UPDATE_ASSET_DIR }}snippets.sql --force --include-default-plugins --force | |
- name: Create hash files | |
run: | | |
mkdir -p engine/Shopware/Components/Check/Data | |
find engine/Shopware themes -type f \( -iname '*.php' -o -iname '*.tpl' -o -iname '*.js' -o -iname '*.less' \) -print0 | xargs -0 md5sum | sort -k 2 -d > engine/Shopware/Components/Check/Data/Files.md5sums | |
- name: Download CaRoot | |
run: | | |
wget -O ./engine/Shopware/Components/HttpClient/cacert.pem https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt | |
- name: Configure git | |
run: | | |
git config --global user.name "shopware5" | |
git config --global user.email "<>" | |
- name: Create Zip | |
run: | | |
rm install.zip | |
rm -rf ./output/release | |
rm -rf _sql | |
git add . | |
git commit -m "Create release package" | |
git archive -v -o ${{ env.PACKAGE_PREFIX }}.zip HEAD | |
zip -r ${{ env.PACKAGE_PREFIX }}.zip ./vendor ./recovery/common/vendor ${{ env.UPDATE_ASSET_DIR }} ${{ env.UPDATE_ASSET_DIR }}version ${{ env.UPDATE_ASSET_DIR }}cleanup.txt ${{ env.UPDATE_ASSET_DIR }}snippets.sql | |
- run: echo "SHA=$(sha1sum ${{ env.PACKAGE_PREFIX }}.zip | awk '{print $1}')" >> $GITHUB_ENV | |
- name: Rename Zip | |
run: | | |
mv ${{ env.PACKAGE_PREFIX }}.zip ${{ env.PACKAGE_PREFIX }}${{ env.PACKAGE_DELIMITER }}${{ env.SHA }}.zip | |
- name: Archive results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ${{ env.PACKAGE_PREFIX }}${{ env.PACKAGE_DELIMITER }}${{ env.SHA }}.zip | |
- name: Push to release | |
uses: xresloader/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: "*.zip" | |
tags: true | |
draft: true |