Skip to content

Commit

Permalink
👷 add release workflow (#65)
Browse files Browse the repository at this point in the history
---

<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>

> ## TL;DR
> This pull request introduces an automated release process for the main branch. The new GitHub workflow will automatically create a new release whenever there is a version change in the `pyproject.toml` file.
> 
> ## What changed
> A new GitHub workflow file `release.yaml` has been added. This workflow is triggered on a push to the main branch. It checks out the repository, sets up Python, installs dependencies, determines if the version has changed by comparing the current version in `pyproject.toml` with the latest release version on GitHub. If a version change is detected, it creates a new release with the new version and generates release notes.
> 
> ## How to test
> To test this change, you can make a commit that changes the version in `pyproject.toml` and push it to the main branch. You should see the workflow triggered in the Actions tab of the GitHub repository. If the workflow runs successfully, a new release should be created with the new version and release notes.
> 
> ## Why make this change
> This change automates the release process, making it easier and more efficient to manage new releases. It ensures that a new release is created whenever there is a version change, reducing the chances of human error. It also automatically generates release notes, providing a summary of changes for each release.
</details>
  • Loading branch information
mingi3314 authored Dec 31, 2023
1 parent ca4e86f commit 9cb6469
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Automated Release Process

on:
push:
branches:
- main

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install toml
- name: Determine Version Change
id: version_check
run: |
# Function to extract version from pyproject.toml
function get_current_version() {
python -c "import toml; print('v' + toml.load('pyproject.toml')['tool']['poetry']['version'])"
}
# Function to get the latest release version from GitHub
function get_latest_release_version() {
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/latest \
| jq -r '.tag_name'
}
VERSION=$(get_current_version)
echo "Current version: $VERSION"
LATEST_RELEASE=$(get_latest_release_version)
echo "Latest release version: $LATEST_RELEASE"
if [ "$VERSION" != "$LATEST_RELEASE" ]; then
echo "Version has changed."
echo "version_changed=true" >> $GITHUB_ENV
echo "new_version=$VERSION" >> $GITHUB_ENV
else
echo "No version change detected."
echo "version_changed=false" >> $GITHUB_ENV
fi
- name: Create Release
if: steps.version_check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version_check.outputs.new_version }}
generate_release_notes: True

0 comments on commit 9cb6469

Please sign in to comment.