Skip to content

Commit 08b11f8

Browse files
committed
Change pipeline to publish by pushing a git tag
1 parent 31450cc commit 08b11f8

File tree

2 files changed

+41
-43
lines changed

2 files changed

+41
-43
lines changed

.github/workflows/create_release.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
name: Deploy packages to PyPI and Anaconda
22
on:
3-
release:
4-
types: [released]
3+
push:
4+
tags:
5+
- 'v*.*.*'
6+
- 'v*.*'
57
jobs:
8+
9+
# Check that the tag matches the lastest version in the code
10+
check-version:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Check version
15+
run: |
16+
# Get the latest version from the code
17+
latest_version=$(sed -r 's/__version__ = "(.*)"/\1/' ravenpackapi/version.py)
18+
# Get the tag from the git tag
19+
tag=$(echo $GITHUB_REF | sed -r 's/refs\/tags\/v(.*)/\1/')
20+
# Check that the tag matches the latest version
21+
if [ "$latest_version" != "$tag" ]; then
22+
echo "The tag $tag does not match the latest version $latest_version"
23+
exit 1
24+
fi
25+
626
# Build packages
727
build:
28+
needs: check-version
829
uses: ./.github/workflows/build.yml
930

1031
# Anaconda
@@ -60,3 +81,21 @@ jobs:
6081
path: dist/
6182
- name: Publish package distributions to PyPI
6283
uses: pypa/gh-action-pypi-publish@release/v1
84+
85+
# Create a release
86+
github-release:
87+
needs: deploy-pypi
88+
name: >-
89+
Create a GitHub Release
90+
runs-on: ubuntu-latest
91+
needs: check-version
92+
steps:
93+
- uses: actions/checkout@v4
94+
- name: Dump the changelog
95+
run: .github/changelogtext.sh > '${{ github.ref_name }}.md'
96+
- name: Create GitHub Release
97+
env:
98+
GITHUB_TOKEN: ${{ github.token }}
99+
run: |
100+
latest_version=$(sed -r 's/__version__ = "(.*)"/\1/' ravenpackapi/version.py)
101+
gh release create '${{ github.ref_name }}' -F '${{ github.ref_name }}.md' --title "Version $latest_version" --repo '${{ github.repository }}'

0 commit comments

Comments
 (0)