forked from simonmartyr/MxPushNotifications
-
Notifications
You must be signed in to change notification settings - Fork 2
115 lines (100 loc) · 4.57 KB
/
export-mpk.yml
File metadata and controls
115 lines (100 loc) · 4.57 KB
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
name: Export module package
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
with:
path: app
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
with:
repository: 'mendixlabs/mx-docker-tools'
path: 'mx-tools'
- name: Define MX_VERSION
run: |
cd $GITHUB_WORKSPACE/app/test
VERSION=$(sqlite3 PushNotfications.mpr 'SELECT _ProductVersion FROM _MetaData LIMIT 1')
echo "Detected Mendix version: $VERSION"
echo "MX_VERSION=$VERSION" >> $GITHUB_ENV
- name: Read package.json
id: set_module_version
run: |
content=`cat $GITHUB_WORKSPACE/app/package.json`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=packageJson::$content"
- name: Define MODULE_VERSION
run: |
MODULE_VERSION=${{fromJson(steps.set_module_version.outputs.packageJson).version}}
echo "Detected module version: $MODULE_VERSION"
echo "MODULE_VERSION=$MODULE_VERSION" >> $GITHUB_ENV
- name: Create output directory
run: mkdir $GITHUB_WORKSPACE/out
- name: Build MX Util
run: |
cd $GITHUB_WORKSPACE/mx-tools
make version=${{env.MX_VERSION}} build
- name: Run MX Util
run: |
MX_TOOLS_IMAGE="mendixlabs/mx-docker-tools:"${{env.MX_VERSION}}
mkdir { $GITHUB_WORKSPACE/app/tmp, $GITHUB_WORKSPACE/app/dist }
docker run -v $GITHUB_WORKSPACE/app:/opt/app -i $MX_TOOLS_IMAGE mxutil.exe create-module-package --package-dir /opt/app/tmp /opt/app/test/PushNotfications.mpr "PushNotifications" --filter-required-libs --exclude-files="resources" | tee $GITHUB_WORKSPACE/out/mxutil.log
cp -f $GITHUB_WORKSPACE/app/tmp/PushNotifications.mpk $GITHUB_WORKSPACE/app/dist/PushNotifications-${{env.MODULE_VERSION}}.mpk
- name: Remove non-whitelisted widgets
run: |
TEMP_UNZIP_FOLDER="$GITHUB_WORKSPACE/temp"
TARGET_MPK="$GITHUB_WORKSPACE/app/dist/PushNotifications-${{env.MODULE_VERSION}}.mpk"
ALLOWED_LIST="$GITHUB_WORKSPACE/app/widgets-whitelist.txt"
if [ ! -f "$ALLOWED_LIST" ]; then
echo “Unable to find file widgets-whitelist.txt”
exit 1;
fi
if [ -d "$TEMP_UNZIP_FOLDER" ]; then rm -Rf $TEMP_UNZIP_FOLDER; fi
mkdir $TEMP_UNZIP_FOLDER
unzip -x $TARGET_MPK -d $TEMP_UNZIP_FOLDER
cd "$TEMP_UNZIP_FOLDER/widgets"
for i in *; do
if ! grep -q "$i" $ALLOWED_LIST; then
echo "Removing widget: $i" | tee -a $GITHUB_WORKSPACE/out/removed-widgets.log
rm "$i"
sed -i "/$i/d" $TEMP_UNZIP_FOLDER/package.xml
fi
done
cd $TEMP_UNZIP_FOLDER
zip -r PushNotifications-${{env.MODULE_VERSION}}.mpk *
mv -f PushNotifications-${{env.MODULE_VERSION}}.mpk $GITHUB_WORKSPACE/app/dist/
if [ -d "$TEMP_UNZIP_FOLDER" ]; then rm -Rf $TEMP_UNZIP_FOLDER; fi
- name: Create release
id: create_release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{env.MODULE_VERSION}}
release_name: Marketplace release v${{env.MODULE_VERSION}}
body: |
(insert release notes)
commitish: master
draft: true
prerelease: false
- name: Upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/app/dist/PushNotifications-${{env.MODULE_VERSION}}.mpk
asset_name: PushNotifications-${{env.MODULE_VERSION}}.mpk
asset_content_type: application/zip
- name: Archive results
if: ${{ always() }}
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2
with:
name: Results
path: ${{ github.workspace }}/out/*