Skip to content

Commit

Permalink
Enable test.pypi.org publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudy committed Apr 9, 2024
1 parent d1a41a3 commit 2809406
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 63 deletions.
121 changes: 58 additions & 63 deletions .github/workflows/pypi-package.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,72 @@
---
name: Build & maybe upload PyPI package
name: Build & maybe upload PyPI package

on:
push:
branches: [main]
tags: ["*"]
release:
types:
- published
workflow_dispatch:
on:
push:
branches: [main]
tags: ["*"]
release:
types:
- published
workflow_dispatch:

permissions:
contents: read
id-token: write
permissions:
contents: read
id-token: write

env:
FORCE_COLOR: "1" # Make tools pretty.
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
env:
FORCE_COLOR: "1" # Make tools pretty.
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"

jobs:
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- name: Set version
if: github.event_name == 'push' && github.ref == 'refs/head/main'
run: |
echo "SETUPTOOLS_SCM_PRETEND_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
jobs:
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2

- uses: hynek/build-and-inspect-python-package@v2
# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
if: github.repository_owner == 'alexrudy' && github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: test-pypi-release
runs-on: ubuntu-latest
needs: build-package

# Upload to Test PyPI on every commit on main.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
if: github.repository_owner == 'alexrudy' && github.ref == 'refs/head/main'
environment: test-pypi-release
runs-on: ubuntu-latest
needs: build-package
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
if: github.repository_owner == 'alexrudy' && github.event.action == 'published'
environment: pypi-release
runs-on: ubuntu-latest
needs: build-package

# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
if: github.repository_owner == 'alexrudy' && github.event.action == 'published'
environment: pypi-release
runs-on: ubuntu-latest
needs: build-package
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "src/bootlace/_version.py"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

[project.urls]
Documentation = "https://github.com/alexrudy/bootlace#readme"
Issues = "https://github.com/alexrudy/bootlace/issues"
Expand Down

0 comments on commit 2809406

Please sign in to comment.