-
-
Notifications
You must be signed in to change notification settings - Fork 135
106 lines (98 loc) · 4.14 KB
/
Release.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
# Workflow for building Kiwix JS store packages for nightly and tagged releases.
name: Release
# Controls when the action will run.
on:
release:
# Triggers the workflow on publishing a release
types:
- published
schedule:
# Nightly run at 01:37 UTC (avoiding the usual midnight surge and rounded times)
- cron: '37 1 * * *'
# Allows us to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
target:
type: choice
description: Do you wish to build release or nightly?
required: false
options:
- release
- nightly
default: 'nightly'
version:
description: If building a release version, please set the version number here, like 9.9 (ignored if you selected nightly build)
required: false
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Build the production version of the app
- name: Build app for production
shell: bash
run: |
npm install
# Build the minified version of the app
npm run build-min
# Remove files we should not be packing
rm -rf dist/www/js/*.map
# Set up secret files from encrypted secrets
- name: Set up secret files and copy needed scripts to dist
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
CHROME_EXTENSION_KEY: ${{ secrets.CHROME_EXTENSION_KEY }}
shell: bash
run: |
mkdir -p ./dist/scripts
echo "$SSH_KEY" > ./dist/scripts/ssh_key
chmod 600 ./dist/scripts/ssh_key
echo "$CHROME_EXTENSION_KEY" > ./dist/scripts/kiwix-html5.pem
chmod 600 ./dist/scripts/kiwix-html5.pem
cp ./scripts/create_all_packages.sh ./dist/scripts/create_all_packages.sh
cp ./scripts/package_chrome_extension.sh ./dist/scripts/package_chrome_extension.sh
cp ./scripts/package_firefox_extension.sh ./dist/scripts/package_firefox_extension.sh
cp ./scripts/package_firefoxos_app.sh ./dist/scripts/package_firefoxos_app.sh
cp ./scripts/package_ubuntu_touch_app.sh ./dist/scripts/package_ubuntu_touch_app.sh
cp -rf ./ubuntu_touch dist/ubuntu_touch
# Set up the environment
- name: Setup environment
shell: bash
run: |
sudo apt-get update
sudo apt-get --yes install ./scripts/ubuntu_touch_packages/*.deb
# Runs the build scripts
- name: Run the build scripts to make extensions and packages
env:
MOZILLA_API_SECRET: ${{ secrets.MOZILLA_API_SECRET }}
MOZILLA_API_KEY: ${{ secrets.MOZILLA_API_KEY }}
TAG_NAME: ${{ github.event.release.tag_name }}
CRON_LAUNCHED: ${{ github.event.schedule }}
INPUT_TARGET: ${{ inputs.target }}
RELEASE_VERSION: ${{ inputs.version }}
shell: bash
# Switch -t indicates a tag release (public release); add -d for dry run (for testing)
# BEFORE the -v switch (because $TAG_NAME is empty for non-public builds)
run: |
# If user dispateched with "nightly", simulate a CRON run
if [ "$INPUT_TARGET" = "nightly" ]; then
CRON_LAUNCHED="nightly"
# Else if use entered a release version, override any tag version
elif [ -n "$RELEASE_VERSION" ]; then
TAG_NAME="$RELEASE_VERSION"
fi
# Run xvfb to make Chrome/Chromium believe it has a display. Else it fails signing the package
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
# Switch to the distribution directory
cd ./dist
if [ -z "$TAG_NAME" ]; then
./scripts/create_all_packages.sh
else
./scripts/create_all_packages.sh -t -v "$TAG_NAME"
fi