Skip to content

Fix: CI release (#36) #24

Fix: CI release (#36)

Fix: CI release (#36) #24

Workflow file for this run

name: Publish release
on:
workflow_dispatch:
push:
tags:
- "202[3-9].0[1-9].[1-9]" # 2023.02.2
- "202[3-9].0[1-9].[1-9]-rc[0-9]+" # 2023.02.2-rc1
- "202[3-9].0[1-9].[1-9][0-9]" # 2023.02.22
- "202[3-9].0[1-9].[1-9][0-9]-rc[0-9]+" # 2023.02.22-rc1
- "202[3-9].1[0-2].[1-9]" # 2023.11.1
- "202[3-9].1[0-2].[1-9]-rc[0-9]+" # 2023.11.1-rc1
- "202[3-9].1[0-2].[1-9][0-9]" # 2023.11.11
- "202[3-9].1[0-2].[1-9][0-9]-rc[0-9]+" # 2023.11.11-rc1
defaults:
run:
shell: bash
jobs:
package:
strategy:
matrix:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version-file: .github/workflows/.python-version
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Install package
run: pip install -e .[test,dist]
- name: Test
run: ./bin/coverage.sh
- name: Package
run: pyinstaller --onefile pyinstaller_entrypoint.py --name hashfields
- name: Make artifact path
id: make-path
env:
ref: ${{ github.ref }}
runner: ${{ runner.os }}
run: |
echo "path=hashfields-${ref/refs\/tags\//}-${runner}.zip" >> $GITHUB_OUTPUT
- name: Zip (Linux)
if: runner.os != 'Windows'
env:
zip_path: ${{ steps.make-path.outputs.path }}
run: |
zip -r -j $zip_path dist/
ls -l $zip_path
- name: Zip (Windows)
if: runner.os == 'Windows'
env:
zip_path: ${{ steps.make-path.outputs.path }}
shell: pwsh
run: |
Compress-Archive -Path .\dist\* -DestinationPath ${env:zip_path}
dir ${env:zip_path}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: package
path: ${{ steps.make-path.outputs.path }}
release:
runs-on: ubuntu-latest
needs: package
permissions:
# https://github.com/softprops/action-gh-release#permissions
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version-file: .github/workflows/.python-version
cache: pip
cache-dependency-path: "**/pyproject.toml"
- name: Install build dependencies
run: pip install -e .[dist]
- name: Build package
run: |
python -m build
ls -al ./dist
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: package
path: ./package
- name: Check artifacts
run: |
ls -al ./package
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
files: |
./dist/*.whl
./dist/*.tar.gz
./package/*.zip
prerelease: ${{ contains(github.ref, '-rc') }}
generate_release_notes: ${{ !contains(github.ref, '-rc') }}
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5
if: ${{ contains(github.ref, '-rc') }}
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
print_hash: true
skip_existing: true
verbose: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5
if: ${{ !contains(github.ref, '-rc') }}
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true