Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ jobs:
pixi run conda-environment env.yml
pixi run requirements requirements.txt

- name: save artifacts
- name: build release artifacts
run: |
pixi run build-package

- name: save artifacts (environment files)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release artifacts
Expand All @@ -43,6 +47,13 @@ jobs:
requirements.txt
if-no-files-found: error

- name: save artifacts (packages)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: built packages
path: dist/*
if-no-files-found: error

extend-release:
needs: build

Expand All @@ -69,3 +80,33 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload $GITHUB_TAG artifacts/env.yml artifacts/requirements.txt

publish-to-pypi:
needs: build
name: Upload PyPI package
if: github.event_name == 'release'

runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/grid4earth

permissions:
id-token: write # allow uploads to pypi.org
attestations: write # allow generating attestations

steps:
- name: download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: built packages
path: dist

- name: Generate artifact attestation
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-path: "dist/*.whl"

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# pixi environments
.pixi/*
!.pixi/config.toml

# auto-generated files
/requirements.txt
/env.yml
/dist/
/grid4earth.egg-info/
44 changes: 44 additions & 0 deletions bump-dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import json
import pathlib
import re
import subprocess

import rich_click as click

dependencies_re = re.compile(r"(?P<name>[-a-z]+)==(?P<version>[0-9]+(?:\.[0-9]+)*)")


def replace_version(match, packages):
name = match.group("name")

return f"{name}=={packages[name]}"


@click.command
def main():
proc = subprocess.run(
["pixi", "ls", "-x", "-e", "default", "--json"],
check=True,
stdout=subprocess.PIPE,
)
package_info = json.loads(proc.stdout)
exclude = {"python"}

filtered = {
p["name"].replace("_", "-"): p["version"]
for p in package_info
if p["name"] not in exclude
}

pyproject_path = pathlib.Path("pyproject.toml")

package_metadata = pyproject_path.read_text()
replaced = dependencies_re.sub(
lambda m: replace_version(m, filtered), package_metadata
)

pyproject_path.write_text(replaced)


if __name__ == "__main__":
main()
Loading