-
Notifications
You must be signed in to change notification settings - Fork 27
162 lines (154 loc) · 5.62 KB
/
build-and-publish.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
name: Publish Release
on:
workflow_dispatch:
push:
tags:
- "*.*.*"
branches:
- 'release/*'
env:
# Workaround for no ternary operator, use short-circuiting
# I'd love to not repeat the version string, but env can't be recursive
VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'DEV' }}
MAC_PACKAGE: OpenCRAVAT.${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'DEV' }}.pkg
WINDOWS_INSTALLER: OpenCRAVAT-${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'DEV' }}.exe
DOCKER_TAG: ${{ secrets.DOCKER_USERNAME }}/opencravat:${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'DEV' }}
DOCKER_ARCHIVE: opencravat-docker-${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'DEV' }}.tgz
PYPI_SDIST: open-cravat-${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'DEV' }}.tar.gz
jobs:
pypi:
runs-on: ubuntu-latest
steps:
- name: Build pypi package
run: echo "Building package on release"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: python setup.py sdist --formats=gztar
- name: Archive Image File
uses: actions/upload-artifact@v4
with:
name: ${{ env.PYPI_SDIST }}
path: ./dist/**
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: ${{ env.DOCKER_TAG }}
- name: Save docker image
run: |
docker image save ${{ env.DOCKER_TAG }} | gzip > opencravat-docker-${{ env.VERSION }}.tgz
- name: Archive installer package
uses: actions/upload-artifact@v4
with:
name: ${{ env.DOCKER_ARCHIVE }}
path: ${{ env.DOCKER_ARCHIVE }}
windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install build tools
run: |
choco install innosetup
- name: Build and Package
working-directory: .build\windows
run: |
.\build.ps1 ..\.. ${{env.VERSION}} -Clean -ForceDownload -Build
- name: Archive installer package
uses: actions/upload-artifact@v4
with:
name: ${{ env.WINDOWS_INSTALLER }}
path: .build\windows\Output\${{ env.WINDOWS_INSTALLER }}
mac:
runs-on: macos-14
env:
MINICONDA_DIST: Miniconda3-py311_24.1.2-0-MacOSX-x86_64
PLATYPUS_RESOURCES: /Applications/Platypus.app/Contents/Resources
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install build tools
run: |
brew install --cask platypus
sudo mkdir -p /usr/local/share/platypus
gunzip ${PLATYPUS_RESOURCES}/platypus_clt.gz
gunzip ${PLATYPUS_RESOURCES}/ScriptExec.gz
chmod +x ${PLATYPUS_RESOURCES}/ScriptExec
sudo cp ${PLATYPUS_RESOURCES}/ScriptExec /usr/local/share/platypus/ScriptExec
sudo cp -r ${PLATYPUS_RESOURCES}/MainMenu.nib /usr/local/share/platypus/MainMenu.nib
curl -o miniconda.sh https://repo.anaconda.com/miniconda/${MINICONDA_DIST}.sh
chmod +x miniconda.sh
./miniconda.sh -b -p ./miniconda -u
- name: Build and Package
run: |
miniconda/bin/conda init bash
. ~/.bash_profile
conda create -y -n py3 python=3.11 pip
conda activate py3
cd .build/mac
${PLATYPUS_RESOURCES}/platypus_clt -a OpenCRAVAT -u "Karchin Lab" -V $VERSION -I org.karchinlab.open-cravat -i ./AppIcon.icns -y ./script ./OpenCRAVAT.app
./make.sh ../..
./package.sh $VERSION
- name: Archive installer package
uses: actions/upload-artifact@v4
with:
name: ${{ env.MAC_PACKAGE }}
path: .build/mac/${{ env.MAC_PACKAGE }}
publish:
runs-on: ubuntu-latest
needs:
- mac
- windows
- pypi
- docker
environment: Published
if: startsWith(github.ref, 'refs/tags/')
steps:
# Downloads all the artifacts from above, and extract them into
# a directory named after the artifact itself, but since the
# artifacts are all named after their contained package the naming
# looks weird.
# An artifact named OpenCravat-2.5.0.exe.zip will extract to a
# directory named OpenCravat-2.5.0.exe and contain
# OpenCravat-2.5.0.exe
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Load Docker Image
run: |
docker load -i ${{ env.DOCKER_ARCHIVE }}/${{ env.DOCKER_ARCHIVE }}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# this should only push since the tagged image was loaded above
- name: Publish Docker image
run: |
docker push ${{ env.DOCKER_TAG }}
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ env.PYPI_SDIST }}
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Release Images
uses: softprops/action-gh-release@v2
with:
draft: true
files: |
- ${{ env.MAC_PACKAGE }}/${{ env.MAC_PACKAGE }}
- ${{ env.WINDOWS_INSTALLER }}/${{ env.WINDOWS_INSTALLER }}