-
Notifications
You must be signed in to change notification settings - Fork 803
140 lines (115 loc) · 6.08 KB
/
create-update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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@v4
- 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@v4
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@v4
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