Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-176: revamp publishing workflow #209

Merged
merged 2 commits into from
Sep 18, 2024
Merged
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
35 changes: 31 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
name: Release

on:
workflow_dispatch:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be manually triggered now to build wheels.

release:
types:
- published

jobs:
dist:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4

- name: Build SDist and wheel
run: pipx run build

- name: Check metadata
run: pipx run twine check dist/*

- uses: actions/upload-artifact@v4
with:
path: dist/*

publish:
name: Publish on PyPI
needs: [dist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
environment:
name: publish
url: https://pypi.org/p/glass
permissions:
id-token: write

steps:
- uses: actions/checkout@v4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how checkout without setting fetch-depth: 0 was working (or maybe it was silently failing)? Given that glass uses VCS for versioning, it becomes important to pull in the entire git history (not a bad thing) to make the versions/tags work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work since it's the release tag itself that is being cloned to a depth of 1 here:

% git clone --branch v2024.1 --depth 1 https://github.com/glass-dev/glass.git glass-v2024.1
% cd glass-v2024.1 
% git describe --tags
v2024.1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, the workflow is triggered when a release is published so the it checkouts on the tag and not the branch. That makes sense, thanks!

- run: pipx run build
- uses: pypa/gh-action-pypi-publish@v1.10.1
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- name: List distributions to be deployed
run: ls -l dist/

- uses: pypa/gh-action-pypi-publish@release/v1