chore(repo): sync with repository template #165
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: Release | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release: | |
name: Create GitHub Release | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
outputs: | |
created: ${{ steps.release.outputs.releases_created }} | |
tag: ${{ steps.release.outputs.tag_name }} | |
steps: | |
- id: release | |
name: Create GitHub Release | |
uses: google-github-actions/release-please-action@v4 | |
with: | |
release-type: python | |
build-pkg: | |
name: Build Package | |
needs: | |
- release | |
if: needs.release.outputs.created == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: poetry | |
- name: Install Dependencies | |
run: poetry install | |
- name: Build Package | |
run: poetry build | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: dist/* | |
strategy: | |
matrix: | |
python-version: | |
- "3.11" | |
build-exe: | |
name: Build Executable | |
needs: | |
- release | |
if: needs.release.outputs.created == 'true' | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Task | |
uses: arduino/setup-task@v2 | |
with: | |
repo-token: ${{ github.token }} | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: poetry | |
- name: Install Dependencies | |
run: poetry install | |
- name: Install GNU Softwares | |
uses: liblaf/template/.github/actions/install@main | |
with: | |
brew: coreutils | |
choco: gnuwin32-coreutils.install | |
- name: Build Executable | |
run: poetry run task dist | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ runner.os }}-${{ runner.arch }}-py${{ matrix.python-version }} | |
path: dist/* | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
python-version: | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
publish: | |
name: Publish to PyPI | |
needs: | |
- release | |
if: needs.release.outputs.created == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Poetry | |
run: pipx install poetry | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: poetry | |
- name: Install Dependencies | |
run: poetry install | |
- name: Publish to PyPI | |
run: poetry publish --build | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | |
strategy: | |
matrix: | |
python-version: | |
- "3.11" | |
upload: | |
name: Upload Release Assets | |
permissions: | |
contents: write | |
needs: | |
- release | |
- build-pkg | |
- build-exe | |
if: needs.release.outputs.created == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- name: Upload Release Assets | |
run: gh release --repo="${{ github.repository }}" upload "${{ needs.release.outputs.tag }}" * --clobber | |
env: | |
GH_TOKEN: ${{ github.token }} |