-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change GitHub Actions to publish to PyPI
- Loading branch information
Showing
2 changed files
with
49 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,57 @@ | ||
name: build_and_release | ||
name: 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: {% raw %}${{ github.workflow }}-${{ github.ref }}{% endraw %} | ||
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: | ||
- 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 | ||
|
||
steps: | ||
- name: "Check out repository" | ||
uses: "actions/checkout@v3" | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: Packages | ||
path: dist | ||
|
||
- name: Generate artifact attestation for sdist and wheel | ||
uses: actions/attest-build-provenance@v1.4.0 | ||
with: | ||
subject-path: "dist/*" | ||
|
||
- name: "Install Conda environment" | ||
uses: "mamba-org/setup-micromamba@v1" | ||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
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 | ||
# Remember to tell (test-)pypi about this repo before publishing | ||
# Remove this line to publish to PyPI | ||
repository-url: https://test.pypi.org/legacy/ |
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