Skip to content

Commit

Permalink
Merge pull request #5 from nsidc/build-for-pypi
Browse files Browse the repository at this point in the history
Build for pypi
  • Loading branch information
mfisher87 authored Aug 16, 2024
2 parents f215814 + e364ced commit 2f7b500
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 79 deletions.
6 changes: 1 addition & 5 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ commit = True
tag = False
message = "Bump version: {current_version} to {new_version}"

[bumpversion:file:./recipe/meta.yaml]
search = version: "{current_version}"
replace = version: "{new_version}"

[bumpversion:file:setup.py]
[bumpversion:file:pyproject.toml]

[bumpversion:file:./gps_timemachine/__init__.py]
search = __version__ = "{current_version}"
Expand Down
74 changes: 43 additions & 31 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
name: build_and_release
name: Build & publish to PyPI

on:
workflow_dispatch:
pull_request:
push:
tags:
- v*
- "v[0-9]+.[0-9]+.[0-9]+*"

# Default to bash in login mode; key to activating conda environment
# https://github.com/mamba-org/provision-with-micromamba#IMPORTANT
defaults:
run:
shell: "bash -l {0}"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3

jobs:
build_and_release:
name: "Run build and release"
runs-on: "ubuntu-latest"
dist:
name: Distribution build
runs-on: ubuntu-latest

steps:
- name: "Check out repository"
uses: "actions/checkout@v3"
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v2

publish:
if: github.ref_type == 'tag'
name: Publish to PyPI
needs: [dist]
environment: pypi
permissions:
id-token: write
attestations: write
contents: read
runs-on: ubuntu-latest

- name: "Install Conda environment"
uses: "mamba-org/setup-micromamba@v1"
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Generate artifact attestation for sdist and wheel
uses: actions/[email protected]
with:
environment-file: "conda-lock.yml"
# When using a lock-file, we have to set an environment name.
environment-name: "gps-timemachine"
cache-environment: true
# Increase this key to trigger cache invalidation
cache-environment-key: 1

- name: "Run conda build"
run: "conda mambabuild --override-channels --channel conda-forge --channel nsidc --channel nodefaults recipe/"

- name: "run anaconda upload"
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
for ARTIFACT in $(ls /home/runner/micromamba/envs/gps-timemachine/conda-bld/noarch/*.tar.bz2) ; do
anaconda -t $ANACONDA_TOKEN upload -u nsidc -l main $ARTIFACT
done
subject-path: "dist/*"

- uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/dist/
*.py[co]
/.nsidc-project.yaml
/.vagrant-*
Expand All @@ -10,4 +11,4 @@
/.vagrant
/.dir-locals.el
*egg-info*
reports
reports
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.1.5 (2024-08-16)

* Initial packaging for PyPI

# v1.1.4 (2024-08-12)

* Update URL for `tai-utc.dat` leap-seconds file.
Expand Down
24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[project]
name = "gps-timemachine"
version = "1.1.4"
description = "Adjust GPS datetimes to UTC."
readme = "README.md"
authors = [
{name = "NSIDC Development Team", email = "[email protected]"},
]
license.file = "LICENSE"
requires-python = ">=3.10"

[project.urls]
Homepage = "https://github.com/nsidc/gps-timemachine"
Repository = "https://github.com/nsidc/gps-timemachine"

[build-system]
requires = ["setuptools>=66"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
exclude = ["tasks"]

[tool.setuptools.package-data]
gps_timemachine = ["static/*.dat"]
28 changes: 0 additions & 28 deletions recipe/meta.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions setup.py

This file was deleted.

0 comments on commit 2f7b500

Please sign in to comment.