Skip to content

Commit

Permalink
[FEAT] Update release flow to create release and publish on merge wit…
Browse files Browse the repository at this point in the history
…h main (#141)

* update release flow

* try this

* try this

* remove dash

* try this

* try this

* try this

* fix version location

* update changelog

* test

* test

* try this

* testitout

* try this

* try this

* try this
  • Loading branch information
Augustinio authored Oct 9, 2024
1 parent a1d535d commit 2aefd48
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 3 deletions.
65 changes: 64 additions & 1 deletion .github/workflows/publish-to-testpypi-and-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
name: Publish pasqal-cloud 📦 to PyPI and TestPyPI

on:
push:
branches:
- dev
- main

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
Expand All @@ -33,7 +37,66 @@ jobs:
with:
password: ${{ secrets.PASQAL_CLOUD_TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PASQAL_CLOUD_PYPI_TOKEN }}

create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build-n-publish
steps:
- uses: actions/checkout@v2

- name: Extract version from _version.py
id: get_version
run: |
version=$(python -c "exec(open('pasqal_cloud/_version.py').read()); print(__version__)")
echo "VERSION=$version" >> $GITHUB_ENV
- name: Get release notes from CHANGELOG.md
run: |
version=${{ env.VERSION }}
# Extract notes from changelog
notes=$(awk -v ver="$version" '
BEGIN { found_version=0; leading_blank=1; }
/## \[/ { if (found_version) { exit } }
/## \['"$version"'\]/ {
found_version=1;
next
}
found_version {
# Remove the _released line
if ($0 ~ /^_released/) { next }
# Remove leading ### or ## or # and any additional whitespace
gsub(/^#+ +/, "", $0);
# Check if the line is blank
if ($0 != "") {
print $0; # Print the current line
leading_blank=0; # Reset leading blank flag
} else if (!leading_blank) {
print ""; # Print a blank line for subsequent empty lines
}
}
' CHANGELOG.md)
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$notes" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Display release notes
run: echo "${{ env.RELEASE_NOTES }}"

- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }}
body: ${{ env.RELEASE_NOTES }}
draft: false
prerelease: false
53 changes: 53 additions & 0 deletions .github/workflows/test_release_notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test release notes to delete before merge
on: push

jobs:
display-github-release-notes:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Extract version from _version.py
id: get_version
run: |
version=$(python -c "exec(open('pasqal_cloud/_version.py').read()); print(__version__)")
echo "VERSION=$version" >> $GITHUB_ENV
- name: Debug CHANGELOG.md
run: cat CHANGELOG.md

- name: Get release notes from CHANGELOG.md
run: |
version=${{ env.VERSION }}
# Extract notes from changelog
notes=$(awk -v ver="$version" '
BEGIN { found_version=0; leading_blank=1; }
/## \[/ { if (found_version) { exit } }
/## \['"$version"'\]/ {
found_version=1;
next
}
found_version {
# Remove the _released line
if ($0 ~ /^_released/) { next }
# Remove leading ### or ## or # and any additional whitespace
gsub(/^#+ +/, "", $0);
# Check if the line is blank
if ($0 != "") {
print $0; # Print the current line
leading_blank=0; # Reset leading blank flag
} else if (!leading_blank) {
print ""; # Print a blank line for subsequent empty lines
}
}
' CHANGELOG.md)
echo "Extracted notes: $notes"
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$notes" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Display release notes
run: echo "${{ env.RELEASE_NOTES }}"
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
All notable changes to this project will be documented in this file.

## [0.12.3]
_released `2024-10-02`_

_released `2024-10-02`

### ✨ Added
- Allow unauthenticated users to access public device specifications

- Allow unauthenticated users to access public device specifications

## [0.12.2] - 2024-09-11

Expand Down

0 comments on commit 2aefd48

Please sign in to comment.