Convert to a multi-step pipeline with all-in-one manual approved publ… #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Release | ||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- "*.*.*" | ||
env: | ||
# Workarouund for no ternary operator, use short-circuiting | ||
VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'DEV' }} | ||
MAC_PACKAGE: OpenCRAVAT.${{env.VERSION}}.pkg | ||
WINDOWS_INSTALLER: OpenCRAVAT-${{env.VERSION}}.exe | ||
DOCKER_TAG: {{ secrets.DOCKER_USERNAME }}/opencravat:${{env.VERSION }} | ||
DOCKER_ARCHIVE: opencravat-docker-${{ env.VERSION }}.tgz | ||
PYPI_SDIST: open-cravat-${{ env.VERSION }}.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: | ||
# the odd path here is to force the action to preseve | ||
# directory structure in the zipfile | ||
name: ${{ env.PYPI_SDIST }} | ||
path: ./dist/${{ env.PYPI_SDIST }} | ||
docker: | ||
runs-on: ubuntu-latest | ||
env: | ||
image_tag: ${{ secrets.DOCKER_USERNAME }}/opencravat:${{ VERSION }} | ||
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 }} |