name: Release # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the master branch push: tags: - "*" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: build-items: description: 'Items to be build' required: true default: 'all' type: choice options: - all - windows - linux - all_incl_release jobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] fail-fast: true steps: - name: Checkout LFS objects run: git clone https://${{secrets.GITHUB_TOKEN}}@gitea.psi.ch/${{ github.repository }}.git . - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install pytest pip install -r requirements.txt - name: Test with pytest run: | export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest tests release: if: ${{ (github.event_name != 'workflow_dispatch') || (contains(fromJson('["all_incl_release"]'), github.event.inputs.build-items)) }} runs-on: ubuntu-latest needs: [test] steps: - uses: actions/checkout@v4 - name: get latest version tag and release note run: | git fetch --depth=500 this_tag=$(python -c "import eos;print('v'+eos.__version__)") prev_tag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) echo "Relese tag $this_tag with changes since $prev_tag" echo "Changes: " > git_changes.log git log $prev_tag..HEAD --pretty=format:"* %s" >> git_changes.log cat git_changes.log echo "RELEASE_TAG=$this_tag" >> $GITHUB_ENV - name: Create Release uses: actions/gitea-release-action@v1 with: name: "Amor-Eos ${{ env.RELEASE_TAG }}" tag_name: "${{ env.RELEASE_TAG }}" body_path: git_changes.log build-ubuntu-latest: needs: [test] runs-on: ubuntu-latest if: ${{ (github.event_name != 'workflow_dispatch') || (contains(fromJson('["all", "linux", "all_incl_release"]'), github.event.inputs.build-items)) }} permissions: id-token: write steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip pip install build pip install -r requirements.txt pip install wheel build twine - name: Build PyPI package run: | python3 -m build - name: Upload to PyPI run: | twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }} --skip-existing this_tag=$(python -c "import eos;print('v'+eos.__version__)") echo "RELEASE_TAG=$this_tag" >> $GITHUB_ENV - name: Update Release if: ${{ (github.event_name != 'workflow_dispatch') || (contains(fromJson('["all_incl_release"]'), github.event.inputs.build-items)) }} uses: actions/gitea-release-action@v1 with: name: "Amor-Eos ${{ env.RELEASE_TAG }}" tag_name: "${{ env.RELEASE_TAG }}" files: |- dist/amor*.tar.gz build-windows: needs: [test] runs-on: windows-latest if: ${{ (github.event_name != 'workflow_dispatch') || (contains(fromJson('["all", "windows", "all_incl_release"]'), github.event.inputs.build-items)) }} steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.12 - name: Ensure build environment shell: powershell run: | $envName="eos_build" $envFile="conda_windows.yml" $hashFile="$env:TEMP\$envName.hash" $newHash = (Get-FileHash $envFile).Hash if (!(Test-Path $hashFile)) { $rebuild = $true } else { $oldHash = Get-Content $hashFile $rebuild = $oldHash -ne $newHash } if ($rebuild) { Write-Host "Environment changed → rebuilding" if (micromamba env list | Select-String $envName) { micromamba env remove -n $envName -y 2>$null } micromamba create -n $envName -f $envFile -y $newHash | Out-File $hashFile } else { Write-Host "Environment unchanged → using cached env" } - name: Determine release tag shell: powershell run: | $tag = micromamba run -n eos_build python -c "import eos; print('v'+eos.__version__)" $tag = $tag.Trim() echo "Release tag extracted: $tag" "RELEASE_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append echo "File written to: $env:GITHUB_ENV" - name: Build with pyinstaller shell: powershell run: | echo "Transferred tag: $RELEASE_TAG or ${{ env.RELEASE_TAG }}." micromamba activate eos_build echo "Transferred tag: $RELEASE_TAG or ${{ env.RELEASE_TAG }}." #pyinstaller windows_build.spec #cd dist\eos #Compress-Archive -Path .\* -Destination ..\..\eos.zip - name: Update Release if: ${{ (github.event_name != 'workflow_dispatch') || (contains(fromJson('["all_incl_release"]'), github.event.inputs.build-items)) }} uses: actions/gitea-release-action@v1 with: name: "Amor-Eos ${{ env.RELEASE_TAG }}" tag_name: "${{ env.RELEASE_TAG }}" files: |- eos.zip