Package Potku #1
This file contains hidden or 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
# Intended to run as a sub-workflow inside bump_version.yml. | |
name: Package Potku | |
on: | |
[workflow_call, workflow_dispatch] | |
jobs: | |
read_version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_content.outputs.version }} | |
steps: | |
- name: Read version file | |
id: get_content | |
run: | | |
cd ${{runner.workspace}}/potku | |
echo "version=$(awk 'NR==1' version.txt)" >> $GITHUB_OUTPUT | |
package_windows: | |
runs-on: windows-latest | |
needs: read_version | |
defaults: | |
run: | |
shell: cmd | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download current C artifact | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: c-apps-windows | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/external | |
check_artifacts: true | |
search_artifacts: true | |
workflow_conclusion: 'in_progress' | |
if_no_artifact_found: ignore | |
- name: Check file existence | |
id: check_files | |
uses: andstor/file-existence-action@v3 | |
with: | |
files: "${{runner.workspace}}/potku/external/bin/mcerd.exe" | |
- name: Download old C artifact | |
if: steps.check_files.outputs.files_exists == 'false' | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: c-apps-windows | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/external | |
check_artifacts: true | |
search_artifacts: true | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
# Semantic version range syntax or exact version of a Python version | |
python-version: '3.12' | |
- name: Collect external files and package Potku | |
run: | | |
cd ${{runner.workspace}}/potku | |
pip install pipenv | |
pipenv install | |
cd ${{runner.workspace}}/potku/dev | |
for /f %%A in ('pipenv run python external_file_manager.py fetch') do set "fails=%%A" | |
if "%fails%" neq "0" ( | |
echo %fails% external files failed to download. | |
exit /b 1 | |
) | |
cd ${{runner.workspace}}/potku | |
pipenv run pip install pyinstaller | |
pipenv run pyinstaller potku.spec | |
- name: Archive Windows release | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Potku-Windows-${{ steps.get_content.outputs.version }} | |
path: ${{runner.workspace}}/potku/dist/ | |
package_linux: | |
runs-on: ubuntu-latest | |
needs: read_version | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download current C artifact | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: c-apps-linux | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/external | |
check_artifacts: true | |
search_artifacts: true | |
workflow_conclusion: 'in_progress' | |
if_no_artifact_found: ignore | |
- name: Check file existence | |
id: check_files | |
uses: andstor/file-existence-action@v3 | |
with: | |
files: "${{runner.workspace}}/potku/external/bin/mcerd" | |
- name: Download old C artifact | |
if: steps.check_files.outputs.files_exists == 'false' | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: c-apps-linux | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/external | |
check_artifacts: true | |
search_artifacts: true | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
# Semantic version range syntax or exact version of a Python version | |
python-version: '3.12' | |
- name: Collect external files and package Potku | |
id: package | |
run: | | |
cd ${{runner.workspace}}/potku | |
pip install pipenv | |
pipenv install | |
cd ${{runner.workspace}}/potku/dev | |
fails=$(pipenv run python external_file_manager.py fetch) | |
if [ "$fails" -ne 0 ]; then | |
echo "$fails external files failed to download." | |
exit 1 | |
fi | |
cd ${{runner.workspace}}/potku | |
pipenv run pip install pyinstaller | |
pipenv run pyinstaller potku.spec | |
- name: Archive Linux release | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Potku-Linux-${{ needs.read_version.outputs.version }} | |
path: ${{runner.workspace}}/potku/dist/ | |
package_macos: | |
runs-on: macos-latest | |
needs: read_version | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download current C artifact | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: c-apps-macos | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/external | |
check_artifacts: true | |
search_artifacts: true | |
workflow_conclusion: 'in_progress' | |
if_no_artifact_found: ignore | |
- name: Check file existence | |
id: check_files | |
uses: andstor/file-existence-action@v3 | |
with: | |
files: "${{runner.workspace}}/potku/external/bin/mcerd" | |
- name: Download old C artifact | |
if: steps.check_files.outputs.files_exists == 'false' | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: c-apps-macos | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/external | |
check_artifacts: true | |
search_artifacts: true | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
# Semantic version range syntax or exact version of a Python version | |
python-version: '3.12' | |
- name: Collect external files and package Potku | |
id: package | |
run: | | |
cd ${{runner.workspace}}/potku | |
pip install pipenv | |
pipenv install | |
cd ${{runner.workspace}}/potku/dev | |
fails=$(pipenv run python external_file_manager.py fetch) | |
if [ "$fails" -ne 0 ]; then | |
echo "$fails external files failed to download." | |
exit 1 | |
fi | |
cd ${{runner.workspace}}/potku | |
pipenv run pip install pyinstaller | |
pipenv run pyinstaller potku.spec | |
- name: Archive macOS release | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Potku-macOS-${{ steps.get_content.outputs.version }} | |
path: ${{runner.workspace}}/potku/dist | |
create_release: | |
needs: [read_version, package_windows, package_linux, package_macos] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Check for pre-release | |
id: pre_release | |
run: | | |
if [[ ${{ needs.read_version.outputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "pre_release=false" >> $GITHUB_OUTPUT | |
else | |
echo "pre_release=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Make directory | |
run: | | |
mkdir -p ${{runner.workspace}}/potku/artifact | |
- name: Download Windows release artifact | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: Potku-Windows-${{ needs.read_version.outputs.version }}.zip }} | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/artifact | |
check_artifacts: true | |
skip_unpack: true | |
workflow_conclusion: 'in_progress' | |
- name: Download Linux release artifact | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: Potku-Linux-${{ needs.read_version.outputs.version }} | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/artifact | |
check_artifacts: true | |
skip_unpack: true | |
workflow_conclusion: 'in_progress' | |
- name: Download macOS release artifact | |
uses: dawidd6/action-download-artifact@v9 | |
with: | |
name: Potku-macOS-${{ needs.read_version.outputs.version }} | |
workflow: version_bump.yml | |
path: ${{runner.workspace}}/potku/artifact | |
check_artifacts: true | |
skip_unpack: true | |
workflow_conclusion: 'in_progress' | |
- name: Create prerelease | |
if: steps.pre_release.outputs.pre_release == 'true' | |
uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1 | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: ${{ needs.read_version.outputs.version }}.zip }} | |
title: Potku ${{ needs.read_version.outputs.version }}.zip }} | |
draft: false | |
prerelease: true | |
files: | | |
${{runner.workspace}}/potku/artifact/Potku-Linux-${{ needs.read_version.outputs.version }}.zip | |
${{runner.workspace}}/potku/artifact/Potku-Windows-${{ needs.read_version.outputs.version }}.zip | |
${{runner.workspace}}/potku/artifact/Potku-macOS-${{ needs.read_version.outputs.version }}.zip | |
- name: Create release | |
if: steps.pre_release.outputs.pre_release == 'false' | |
uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1 | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
automatic_release_tag: ${{ needs.read_version.outputs.version }}.zip }} | |
title: Potku ${{ steps.get_content.outputs.version }} | |
draft: true | |
prerelease: false | |
files: | | |
${{runner.workspace}}/potku/artifact/Potku-Linux-${{ needs.read_version.outputs.version }}.zip }}.zip | |
${{runner.workspace}}/potku/artifact/Potku-Windows-${{ needs.read_version.outputs.version }}.zip }}.zip | |
${{runner.workspace}}/potku/artifact/Potku-macOS-${{ needs.read_version.outputs.version }}.zip }}.zip |