WIP: Adding creating release to publish package #89
Workflow file for this run
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: Package | |
on: | |
push: | |
tags: | |
- 'latest' | |
- 'v*' | |
branches-ignore: | |
- '**' | |
pull_request: | |
paths: | |
- .github/workflows/Package.yml | |
workflow_dispatch: | |
jobs: | |
package-docker: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
max-parallel: 4 | |
matrix: | |
include: | |
- os: ubuntu-latest | |
dockerfile: Dockerfile-2014-x86_64 | |
env: | |
PYTHON_VERSIONS: "cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312" | |
BUILD_CSHARP: ${{ contains(matrix.os, 'arm') && '0' || '1' }} | |
BUILD_JAVA: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build ${{ matrix.dockerfile }} | |
shell: bash | |
working-directory: Utilities/Distribution/manylinux | |
run: | | |
mkdir -p Utilities/Distribution/manylinux/wheelhouse | |
echo "data" > Utilities/Distribution/manylinux/wheelhouse/SimpleITK-${{ matrix.os }}.whl | |
- name: ls | |
shell: bash | |
working-directory: Utilities/Distribution/manylinux | |
run: | | |
ls -lhR . | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{ matrix.os }} | |
path: | | |
Utilities/Distribution/manylinux/wheelhouse/*.whl | |
Utilities/Distribution/manylinux/SimpleITK*.zip | |
build: | |
runs-on: ${{ matrix.os }} | |
env: | |
COREBINARYDIRECTORY: "${{ github.workspace }}/bld" | |
ExternalData_OBJECT_STORES: "${{ github.workspace }}/.ExternalData" | |
DASHBOARD_BRANCH_DIRECTORY: "${{ github.workspace }}/SimpleITK-dashboard" | |
CTEST_SOURCE_DIRECTORY: "${{ github.workspace }}" | |
CTEST_CONFIGURATION_TYPE: "${{ matrix.cmake-build-type }}" | |
strategy: | |
fail-fast: false | |
max-parallel: 4 | |
matrix: | |
include: | |
- os: macos-13 | |
cmake-build-type: "Release" | |
cmake-generator: "Ninja" | |
ctest-cache: | | |
CMAKE_CXX_FLAGS:STRING=-fvisibility=hidden -fvisibility-inlines-hidden | |
CMAKE_C_FLAGS:STRING=-fvisibility=hidden | |
CMAKE_OSX_DEPLOYMENT_TARGET=10.9 | |
ITK_C_OPTIMIZATION_FLAGS:STRING= | |
ITK_CXX_OPTIMIZATION_FLAGS:STRING= | |
SimpleITK_BUILD_DISTRIBUTE:BOOL=ON | |
- os: windows-2019 | |
cmake-build-type: "Release" | |
cmake-generator: "Visual Studio 16 2019" | |
cmake-generator-toolset: v142,host=x64 | |
cmake-generator-platform: x64 | |
ctest-cache: | | |
BUILD_EXAMPLES:BOOL=ON | |
BUILD_TESTING:BOOL=ON | |
ITK_C_OPTIMIZATION_FLAGS:STRING= | |
ITK_CXX_OPTIMIZATION_FLAGS:STRING= | |
SimpleITK_BUILD_DISTRIBUTE:BOOL=ON | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/checkout@v4 | |
with: | |
path: SimpleITK-dashboard | |
ref: dashboard | |
- name: Generate External Data Hash | |
shell: bash | |
run: | | |
mkdir -p ${ExternalData_OBJECT_STORES} | |
ls -la "${{ github.workspace }}/Testing/Data/" | |
git log -n 1 "${{ github.workspace }}/Testing/Data/" | tee "${{ github.workspace }}/external-data.hashable" | |
- uses: actions/cache@v4 | |
id: cache | |
with: | |
path: ${{ env.ExternalData_OBJECT_STORES }} | |
key: external-data-v1-${{ hashFiles( format( '{0}/{1}', github.workspace, 'external-data.hashable') ) }} | |
enableCrossOsArchive: true | |
restore-keys: | | |
external-data-v1- | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
id: cpy | |
with: | |
python-version: 3.11 | |
- name: Install build dependencies | |
shell: bash | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install ninja cmake~=3.22.0 | |
if [ ! -z "${{ matrix.xcode-version }}" ]; then | |
sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer/ | |
xcode-select -p | |
fi | |
- name: Build and Test | |
shell: bash | |
env: | |
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS: 2 | |
CTEST_BINARY_DIRECTORY: "${{ env.COREBINARYDIRECTORY }}" | |
CTEST_CMAKE_GENERATOR: "${{ matrix.cmake-generator }}" | |
CTEST_CMAKE_GENERATOR_TOOLSET: "${{ matrix.cmake-generator-toolset }}" | |
CTEST_CMAKE_GENERATOR_PLATFORM: "${{ matrix.cmake-generator-platform }}" | |
CTEST_OUTPUT_ON_FAILURE: 1 | |
CTEST_CACHE: | | |
WRAP_DEFAULT:BOOL=OFF | |
BUILD_EXAMPLES:BOOL=ON | |
BUILD_TESTING:BOOL=ON | |
${{ matrix.ctest-cache }} | |
run: | | |
mkdir artifacts | |
echo "test" > artifacts/SimpleITK-${{ matrix.os }}.whl | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{ matrix.os }} | |
path: | | |
${{ github.workspace }}/artifacts/*.whl | |
${{ github.workspace }}/artifacts/*.zip | |
publish: | |
if: github.ref == 'refs/tags/latest' | |
needs: | |
- build | |
- package-docker | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v4 | |
id: download | |
with: | |
path: ${{ github.workspace }}/artifacts | |
- name: Checksums | |
shell: bash | |
run: | | |
sha256sum $( find ${{ steps.download.outputs.download-path }} -type f -name "*.gz" "*.whl" -o -name "*.zip" ) > checksums.txt | |
echo "== checksums.txt ==" | |
cat checksums.txt | |
- name: Create Release Notes | |
shell: bash | |
run: | | |
echo "This is an automatic pre-release packaging of SimpleITK based on the master branch. It contains the latest features and experimental developments. | |
To upgrade to the latest pre-release Python binary package run: | |
\`\`\`pip install --upgrade --pre SimpleITK --find-links https://github.com/SimpleITK/SimpleITK/releases/tag/latest\`\`\` | |
" >notes.txt | |
for f in $( find ${{ steps.download.outputs.download-path }} -type f ) | |
do | |
if [[ $f == *.whl ]]; then | |
md5=$(md5sum $f | awk '{ print $1 }') | |
echo -n "<a href=\"https://github.com/SimpleITK/SimpleITK/releases/download/latest/$(basename $f)#${md5}\"></a>" >> notes.txt | |
fi | |
done | |
echo "== notes.txt ==" | |
cat notes.txt | |
- name: Create Release and Upload Artifacts | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG_NAME: ${{ github.ref_name }} | |
run: | | |
gh release delete ${TAG_NAME}-draft --yes || true | |
gh release create ${TAG_NAME}-draft \ | |
--target ${{ github.sha }} \ | |
--draft \ | |
--generate-notes \ | |
--prerelease \ | |
--notes-file notes.txt \ | |
--title "Release ${{ github.ref_name }}" | |
gh release upload ${TAG_NAME}-draft $( find ${{ steps.download.outputs.download-path }} -type f -name "*.whl" -o -name "*.zip" -o -name "*.gz" ) | |
gh release edit ${TAG_NAME}-draft --tag ${TAG_NAME} |