-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (156 loc) · 6.52 KB
/
hugo-cordova-runner.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Build, Deploy, and APK
on:
push:
branches: ["gradle"]
workflow_dispatch:
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
check-keystore:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check if KEYSTORE_FILE secret is empty
run: |
if [ -z "${{ secrets.KEYSTORE_FILE }}" ]; then
echo "Keystore secret is empty. Exiting..."
exit 1
fi
- name: Restore Keystore
run: |
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > mg-build-release-key.keystore
- name: Verify Keystore File Size
run: |
if [ ! -s mg-build-release-key.keystore ]; then
echo "Keystore file is empty. Exiting..."
exit 1
fi
- name: List Keystore Contents
run: |
keytool -list -v -keystore mg-build-release-key.keystore -storepass "${{ secrets.KEYSTORE_PASSWORD }}"
env:
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64
- name: Clean up
run: rm -f mg-build-release-key.keystore # Use -f to avoid errors if the file doesn't exist
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.128.0
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
HUGO_ENVIRONMENT: production
run: hugo --minify --baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./gradle/public
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
build-apk:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Restore Keystore
run: |
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > mg-build-release-key.keystore
- name: Verify Keystore File Size
run: |
if [ ! -s mg-build-release-key.keystore ]; then
echo "Keystore file is empty or not restored. Exiting..."
exit 1
fi
- name: Copy Keystore to Correct Location
run: |
cp mg-build-release-key.keystore "${GITHUB_WORKSPACE}/cordovaProject/key/mg-build-release-key.keystore"
- name: Build APK using Docker
run: |
REPO_URL="${{ github.event.repository.html_url }}"
REPO_NAME=$(basename -s .git "$REPO_URL")
APP_NAME=$(echo "$REPO_NAME" | sed -e 's/-/ /g' -e 's/^./\U&/')
PACKAGE_NAME=$(echo "$REPO_URL" | sed 's|https://github.com/||;s|/|.|g;s|.git$||;s|-|.|g;s|[^a-zA-Z0-9.]||g')
docker run --rm -v "${{ github.workspace }}:/github/workspace" -w /github/workspace mobagenie/mgbuild:v1 sh -c "
sed -i 's/appNameReplace/$APP_NAME/g; s/appDescReplace/$APP_NAME/g' cordovaProject/config.xml &&
sed -i 's/pkgNameReplace/$PACKAGE_NAME/g; s/displayNameReplace/$APP_NAME/g; s/appDescReplace/$APP_NAME/g' cordovaProject/package.json &&
cp -r gradle/public/* cordovaProject/www &&
cd cordovaProject &&
cordova platform add android &&
cordova build android --release -- --packageType=apk --keystore=key/mg-build-release-key.keystore --storePassword=${{ secrets.KEYSTORE_PASSWORD }} --alias=${{ secrets.KEY_ALIAS }} --password=${{ secrets.KEY_PASSWORD }} --keystoreType=jks"
- name: Archive APKs
run: |
REPO_URL="${{ github.event.repository.html_url }}"
REPO_NAME=$(basename -s .git "$REPO_URL")
APP_NAME=$(echo "$REPO_NAME" | sed -e 's/-/ /g' -e 's/^./\U&/')
PACKAGE_NAME=$(echo "$REPO_URL" | sed 's|https://github.com/||;s|/|.|g;s|.git$||;s|-|.|g;s|[^a-zA-Z0-9.]||g')
mkdir -p apk
cp -r cordovaProject/platforms/android/app/build/outputs/apk/release/*.apk apk/
echo "APK files in apk directory:"
ls apk
- name: Set tag and release name
id: set_release_info
run: |
TAG_NAME="release-$(echo $GITHUB_SHA | cut -c1-7)"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "RELEASE_NAME=Release $(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Create asset name
id: create_asset_name
run: |
REPO_URL="${{ github.event.repository.html_url }}"
REPO_NAME=$(basename -s .git "$REPO_URL")
APP_NAME=$(echo "$REPO_NAME" | sed -e 's/-/ /g' -e 's/^./\U&/')
PACKAGE_NAME=$(echo "$REPO_URL" | sed 's|https://github.com/||;s|/|.|g;s|.git$||;s|-|.|g;s|[^a-zA-Z0-9.]||g')
echo "ASSET_NAME=com.${PACKAGE_NAME}-$(echo $GITHUB_SHA | cut -c1-7).apk" >> $GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.TAG_NAME }}
release_name: ${{ env.RELEASE_NAME }}
body: "APK build for gradle branch"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload APK to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: apk/app-release.apk # Ensure this matches the APK filename
asset_name: ${{ env.ASSET_NAME }} # Reference the asset name here
asset_content_type: application/vnd.android.package-archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up Keystore
run: rm -f mg-build-release-key.keystore # Use -f to avoid errors if the file doesn't exist