Skip to content

Commit b39e86a

Browse files
authored
Add release workflow (#3)
This is based on the revised workflow at Qiskit/qiskit-addon-utils#212.
1 parent db82570 commit b39e86a

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build and publish
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "[0-9]+.[0-9]+.[0-9]+"
8+
branches:
9+
- main
10+
- 'stable/**'
11+
12+
jobs:
13+
14+
build_sdist:
15+
name: Build source distribution
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v7
19+
- name: Build distribution
20+
run: |
21+
pipx run build --sdist
22+
- name: Store the distribution packages
23+
uses: actions/upload-artifact@v7
24+
with:
25+
name: pkg-sdist
26+
path: dist/*.tar.gz
27+
28+
# PyPI is published before the GitHub release because a PyPI upload is
29+
# irreversible (a version can be yanked, but the filename can never be
30+
# reused), whereas a GitHub release can simply be deleted and recreated. If
31+
# only one of the two succeeds, it should be the one that cannot be redone.
32+
pypi:
33+
name: Publish to pypi
34+
if: startsWith(github.ref, 'refs/tags/')
35+
runs-on: ubuntu-latest
36+
needs:
37+
- build_sdist
38+
environment:
39+
name: pypi
40+
url: https://pypi.org/p/sbd-eigensolver
41+
permissions:
42+
id-token: write
43+
steps:
44+
- name: Download artifacts
45+
uses: actions/download-artifact@v8
46+
with:
47+
pattern: pkg-*
48+
path: dist
49+
merge-multiple: true
50+
- name: Publish release to PyPI
51+
uses: pypa/gh-action-pypi-publish@release/v1
52+
53+
github:
54+
name: Publish to GitHub
55+
if: startsWith(github.ref, 'refs/tags/')
56+
runs-on: ubuntu-latest
57+
needs:
58+
- build_sdist
59+
- pypi
60+
permissions:
61+
contents: write
62+
steps:
63+
- name: Download artifacts
64+
uses: actions/download-artifact@v8
65+
with:
66+
pattern: pkg-*
67+
path: dist
68+
merge-multiple: true
69+
- name: Generate checksums
70+
working-directory: dist
71+
run: sha256sum -- * > checksums.sha256
72+
- name: Publish release
73+
env:
74+
GH_TOKEN: ${{ github.token }}
75+
run: >-
76+
gh release create
77+
'${{ github.ref_name }}'
78+
--repo '${{ github.repository }}'
79+
--title '${{ github.ref_name }}'
80+
--generate-notes
81+
--verify-tag
82+
dist/*

0 commit comments

Comments
 (0)