Skip to content

Commit

Permalink
Improve github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinepouille committed Sep 25, 2024
1 parent 5bc353a commit 0b73cde
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 107 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
88 changes: 16 additions & 72 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# needs `opam exec --` as `dune` is not in the shell PATH
opam exec -- dune fmt --preview
install-ubuntu:
ubuntu:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand Down Expand Up @@ -107,8 +107,7 @@ jobs:
poppler-utils graphviz texlive-latex-recommended \
texlive-fonts-recommended texlive-pictures tex4ht
- name: Install OPAM dependencies
run: |
opam install --yes . --deps-only
run: opam install --yes . --deps-only
- name: Make Kappa
run: opam exec -- make all
- name: Make Javascript app
Expand Down Expand Up @@ -136,8 +135,7 @@ jobs:
with:
ocaml-compiler: 4.13.x
- name: Install OPAM dependencies
run: |
opam install --yes . --deps-only
run: opam install --yes . --deps-only
- name: Make Kappa
run: opam exec -- make all
- name: Make MacOS app
Expand All @@ -154,8 +152,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: macos
path: |
Kappapp.app.zip
path: Kappapp.app.zip

windows:
runs-on: windows-2022
Expand All @@ -167,28 +164,29 @@ jobs:
with:
ocaml-compiler: 4.14.x
- name: Install OPAM dependencies
run: |
opam install --yes . --deps-only
run: opam install --yes . --deps-only
- name: Make Kappa
run: opam exec -- make all
- name: Make Windows app
run: |
opam exec -- make KappaBin
opam exec -- make KappappWin
# Note: This runs powershell thus the different path syntax
mv .\build\KappaBin .
mv .\build\KappappWin .
# Note: Windows VMs on GitHub Action do not have zip command but provide 7z
7z a -tzip KappaBin.zip KappaBin
7z a -tzip KappappWin.zip KappappWin
- name: Archive Windows app
uses: actions/upload-artifact@v4
with:
name: windows
path: |
KappaBin.zip
path: KappappWin.zip

deploy-docs:
needs: install-ubuntu
runs-on: ubuntu-22.04
deploy:
needs: [ubuntu, js, macos, windows]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
strategy:
matrix:
deploy-name: [doc, online-ui, linux, macos, windows]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -201,58 +199,4 @@ jobs:
with:
key: ${{ secrets.DEPLOY_KEY }}
known_hosts: api.kappalanguage.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJooIEJd6sgRL5JUKGqh9zB3Xla1MchqR8IWl7Nh9ahm9Ji6IwV9QSKG9YQEIHdJWxBk4UzbfRWGkDK9q1GggyM=
- run: dev/update-web.sh native

deploy-js:
needs: js
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download js artifact
uses: actions/download-artifact@v4
with:
name: js
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_KEY }}
known_hosts: api.kappalanguage.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJooIEJd6sgRL5JUKGqh9zB3Xla1MchqR8IWl7Nh9ahm9Ji6IwV9QSKG9YQEIHdJWxBk4UzbfRWGkDK9q1GggyM=
- run: dev/update-web.sh js

deploy-macos:
needs: macos
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download MacOS artifact
uses: actions/download-artifact@v4
with:
name: macos
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_KEY }}
known_hosts: api.kappalanguage.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJooIEJd6sgRL5JUKGqh9zB3Xla1MchqR8IWl7Nh9ahm9Ji6IwV9QSKG9YQEIHdJWxBk4UzbfRWGkDK9q1GggyM=
- run: dev/update-web.sh MacOS

deploy-windows:
needs: windows
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: windows
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_KEY }}
known_hosts: api.kappalanguage.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJooIEJd6sgRL5JUKGqh9zB3Xla1MchqR8IWl7Nh9ahm9Ji6IwV9QSKG9YQEIHdJWxBk4UzbfRWGkDK9q1GggyM=
- run: dev/update-web.sh windows
- run: dev/upload-website.sh ${{matrix.deploy-name}}
55 changes: 33 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ endif
.PHONY: all agents clean check build-tests doc clean_doc debug
.PHONY: temp-clean-for-ignorant-that-clean-must-be-done-before-fetch
.PHONY: profiling kappalib install-lib
.PHONY: Kappapp Kappapp.tar.gz KappaBin KappaBin.zip Kappapp.app
.PHONY: Kappapp Kappapp.tar.gz KappappWin KappappWin.zip Kappapp.app

.PRECIOUS: $(SCRIPTSWITNESS)

Expand Down Expand Up @@ -171,6 +171,7 @@ build/Kappapp:
mkdir build/Kappapp/resources/bin
cp _build/install/default/bin/* build/Kappapp/resources/bin/

## Electron build for linux
Kappapp:
# make clean before to be sure things are rebuilt TODO improve?
+$(MAKE) clean
Expand All @@ -182,35 +183,36 @@ build/Kappapp.tar.gz: build/Kappapp

Kappapp.tar.gz: build/Kappapp.tar.gz

build/KappaBin:
mkdir -p build/KappaBin
build/KappappWin:
mkdir -p build/KappappWin
+$(MAKE) APP_EXT=local build/site/index.html
dune build --only-packages kappa-library,kappa-binaries,kappa-agents
FILE=$$(mktemp -t electronXXXX); \
curl -LsS -o $$FILE https://github.com/electron/electron/releases/download/v$(ELECTRON_VERSION)/electron-v$(ELECTRON_VERSION)-win32-x64.zip && \
unzip $$FILE -d build/KappaBin
mv build/site build/KappaBin/resources/app
mv build/KappaBin/electron.exe build/KappaBin/Kappapp.exe
mkdir build/KappaBin/resources/bin
cp _build/default/core/main/KaSim.exe build/KappaBin/resources/bin/
cp _build/default/core/KaSa_rep/main/KaSa.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaStor.exe build/KappaBin/resources/bin/
cp _build/default/core/odes/KaDE.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KappaSwitchman.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaMoHa.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaSimAgent.exe build/KappaBin/resources/bin/
cp _build/default/core/agents/KaSaAgent.exe build/KappaBin/resources/bin/

KappaBin:
unzip $$FILE -d build/KappappWin
mv build/site build/KappappWin/resources/app
mv build/KappappWin/electron.exe build/KappappWin/Kappapp.exe
mkdir build/KappappWin/resources/bin
cp _build/default/core/main/KaSim.exe build/KappappWin/resources/bin/
cp _build/default/core/KaSa_rep/main/KaSa.exe build/KappappWin/resources/bin/
cp _build/default/core/agents/KaStor.exe build/KappappWin/resources/bin/
cp _build/default/core/odes/KaDE.exe build/KappappWin/resources/bin/
cp _build/default/core/agents/KappaSwitchman.exe build/KappappWin/resources/bin/
cp _build/default/core/agents/KaMoHa.exe build/KappappWin/resources/bin/
cp _build/default/core/agents/KaSimAgent.exe build/KappappWin/resources/bin/
cp _build/default/core/agents/KaSaAgent.exe build/KappappWin/resources/bin/

## Electron build for windows
KappappWin:
# make clean before to be sure things are rebuilt TODO improve?
+$(MAKE) clean
+$(MAKE) build/KappaBin
+$(MAKE) build/KappappWin

build/KappaBin.zip: build/KappaBin
zip -y -r $@ build/KappaBin
rm -rf build/KappaBin
build/KappappWin.zip: build/KappappWin
zip -y -r $@ build/KappappWin
rm -rf build/KappappWin

KappaBin.zip: build/KappaBin.zip
KappappWin.zip: build/KappappWin.zip

build/Kappapp.app: build/Info.plist build/Kappa.icns
# do not call make clean here or deps will be erased
Expand All @@ -227,6 +229,7 @@ build/Kappapp.app: build/Info.plist build/Kappa.icns
mv build/Kappa.icns $@/Contents/Resources/
mv build/Info.plist $@/Contents/

# Electron build for MacOS 10.15
Kappapp.app:
# make clean before to be sure things are rebuilt TODO improve?
+$(MAKE) clean
Expand Down Expand Up @@ -254,3 +257,11 @@ build/Kappa.iconset: gui/resources/Kappa-Logo.png
build/Kappa.icns: build/Kappa.iconset
mkdir -p build
iconutil -c icns $<

.PHONY: Kappapp_for_linux Kappapp_for_macos10.15 Kappapp_for_windows

Kappapp_for_linux: Kappapp

Kappapp_for_macos10.15: Kappapp.app

Kappapp_for_windows: KappappWin
28 changes: 15 additions & 13 deletions dev/update-web.sh → dev/upload-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ empty_or_create ()
PLAYGROUND=$(mktemp -d -t kappaXXXX)
git clone --depth 10 --quiet -b master [email protected]:Kappa-Dev/Kappa-Dev.github.io.git ${PLAYGROUND}
case $1 in
native )
doc )
empty_or_create ${PLAYGROUND}/docs/KaSim-manual-${TRAVIS_BRANCH}
cp man/*.htm man/*.css ${PLAYGROUND}/docs/KaSim-manual-${TRAVIS_BRANCH}/
cp man/KaSim_manual.pdf ${PLAYGROUND}/docs/KaSim-manual-${TRAVIS_BRANCH}.pdf
Expand All @@ -29,7 +29,7 @@ case $1 in
scp -r \
${PLAYGROUND}/docs [email protected]:/var/www/tools.kappalanguage.org/
;;
js )
online-ui )
empty_or_create ${PLAYGROUND}/try
cp site/* ${PLAYGROUND}/try/
sed '/<\/head>/i \
Expand All @@ -51,31 +51,33 @@ case $1 in
' site/index.html > ${PLAYGROUND}/try/index.html
scp -o UserKnownHostsFile=dev/deploy_hosts -i dev/travis-deploy -r \
${PLAYGROUND}/try [email protected]:/var/www/tools.kappalanguage.org/

# Upload /viz interface alongside /try
empty_or_create ${PLAYGROUND}/viz
cp viz/* ${PLAYGROUND}/viz/
scp -o UserKnownHostsFile=dev/deploy_hosts -i dev/travis-deploy -r \
${PLAYGROUND}/viz [email protected]:/var/www/tools.kappalanguage.org/
;;
linux )
[ -d ${PLAYGROUND}/binaries ] || mkdir ${PLAYGROUND}/binaries
cp Kappapp.tar.gz ${PLAYGROUND}/binaries/
scp ${PLAYGROUND}/binaries/Kappapp.tar.gz \
cp Kappapp.tar.gz ${PLAYGROUND}/binaries/Kappapp_linux.tar.gz
scp ${PLAYGROUND}/binaries/Kappapp_linux.tar.gz \
[email protected]:/var/www/tools.kappalanguage.org/nightly-builds/
;;
python )
;;
'' )
;;
windows )
[ -d ${PLAYGROUND}/binaries ] || mkdir ${PLAYGROUND}/binaries
cp KappaBin.zip ${PLAYGROUND}/binaries/
scp ${PLAYGROUND}/binaries/KappaBin.zip \
cp KappappWin.zip ${PLAYGROUND}/binaries/Kappapp_windows.zip
scp ${PLAYGROUND}/binaries/Kappapp_windows.zip \
[email protected]:/var/www/tools.kappalanguage.org/nightly-builds/
;;
MacOS )
macos )
[ -d ${PLAYGROUND}/binaries ] || mkdir ${PLAYGROUND}/binaries
cp Kappapp.app.zip ${PLAYGROUND}/binaries/
scp ${PLAYGROUND}/binaries/Kappapp.app.zip \
cp Kappapp.app.zip ${PLAYGROUND}/binaries/Kappapp_macos10.15.app.zip
scp ${PLAYGROUND}/binaries/Kappapp_macos10.15.app.zip \
[email protected]:/var/www/tools.kappalanguage.org/nightly-builds/
;;
'' )
;;
esac
COMMITNAME=$(git show --pretty=oneline -s --no-color)
cd ${PLAYGROUND}
Expand Down

0 comments on commit 0b73cde

Please sign in to comment.