fix ci x16 #222
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: Lint & release project | |
on: | |
push: | |
paths: | |
- "pyproject.toml" | |
- "poetry.lock" | |
- "tgpy/**" | |
- ".github/workflows/main.yml" | |
- ".github/workflows/docker.yml" | |
pull_request: | |
paths: | |
- "pyproject.toml" | |
- "poetry.lock" | |
- "tgpy/**" | |
- ".github/workflows/main.yml" | |
- ".github/workflows/docker.yml" | |
workflow_dispatch: {} | |
jobs: | |
Lint: | |
runs-on: ubuntu-latest | |
if: false | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Load dependency cache | |
id: load-cache | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: app-${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('poetry.lock') }} | |
- name: Install dependencies | |
run: | | |
nix develop -c poetry config virtualenvs.in-project true | |
nix develop -c poetry install | |
if: steps.load-cache.outputs.cache-hit != 'true' | |
- name: Check code style | |
if: github.event_name != 'push' | |
run: | | |
nix develop -c poetry run black --check --diff . | |
nix develop -c poetry run isort --check --diff . | |
- name: Reformat code | |
if: github.event_name == 'push' | |
run: | | |
nix develop -c poetry run black . | |
nix develop -c poetry run isort . | |
- name: Commit chanes | |
if: github.event_name == 'push' | |
shell: bash | |
run: | | |
if [ ! -n "$(git status --porcelain)" ]; then | |
exit | |
fi | |
git add -A | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git commit -m "style: reformat [skip ci]" | |
git push | |
Release: | |
concurrency: release | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Load dependency cache | |
id: load-cache | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: app-${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('poetry.lock') }} | |
- name: Install dependencies | |
run: | | |
nix develop -c poetry config virtualenvs.in-project true | |
nix develop -c poetry install --with release | |
if: steps.load-cache.outputs.cache-hit != 'true' | |
- name: Release | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
function prun() { | |
nix develop -c poetry run python -m "$@" | |
} | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
prun semantic_release version | |
export TWINE_USERNAME="__token__" | |
export TWINE_PASSWORD="${PYPI_TOKEN}" | |
prun twine upload -r testpypi dist/* | |
export GH_TOKEN="${GITHUB_TOKEN}" | |
prun semantic_release publish | |
- name: Save release commit hash | |
id: release-commit-hash | |
run: echo "::set-output name=release-commit-hash::$(git rev-parse HEAD)" | |
outputs: | |
release-commit-hash: ${{ steps.release-commit-hash.outputs.release-commit-hash }} | |
Build-dev-docker: | |
needs: Lint | |
name: Build dev docker image | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref != 'refs/heads/master' | |
uses: ./.github/workflows/docker.yml | |
secrets: inherit | |
Build-release-docker: | |
name: Build release docker image | |
needs: Release | |
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/master' | |
uses: ./.github/workflows/docker.yml | |
with: | |
commit-hash: ${{ needs.Release.outputs.release-commit-hash }} | |
secrets: inherit |