Skip to content

Commit

Permalink
Change version in pyproject; update release workflow to check pyproje…
Browse files Browse the repository at this point in the history
…ct as well
  • Loading branch information
chtsai0105 committed Nov 15, 2023
1 parent 8b83539 commit 6e9c476
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 37 deletions.
89 changes: 53 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:

jobs:
version_check:
Expand All @@ -14,53 +15,69 @@ jobs:
with:
sparse-checkout: |
README.md
pyproject.toml
sparse-checkout-cone-mode: false
fetch-tags: true
token: ${{ secrets.GITHUB_TOKEN }}
ref: master
ref: main

- name: Capture version in README.md
id: file
- name: Get repo name
id: repo
run: |
repo_name=$(basename "$GITHUB_REPOSITORY")
cap=$(grep -oP "${repo_name}-v\K\d\.\d\.\d[^\s]*" README.md)
echo "version=$cap" >> "$GITHUB_OUTPUT"
echo "repo_name=$repo_name" >> "$GITHUB_OUTPUT"
- name: Capture version in latest tag
id: tag
run: echo "version=$(git tag --sort=committerdate -l "v*" | tail -n1 | sed 's/^v//')" >> "$GITHUB_OUTPUT"
run: echo "$(git tag -l "v*")"

- name: Substitute version in README.md
id: sub
if: ${{ steps.file.outputs.version != steps.tag.outputs.version }}
run: sed -i 's/${{ steps.file.outputs.repo_name}}-${{ steps.file.outputs.version }}/${{ steps.file.outputs.repo_name}}-${{ steps.tag.outputs.version }}/g' README.md
# - name: Check version in README.md
# id: readme
# run: |
# cap=$(grep -oP "${{ steps.repo.outputs.repo_name }}-\K\d\.\d\.\d[^\s]*" README.md)
# echo "version=$cap" >> "$GITHUB_OUTPUT"

- name: Push changes
if: steps.sub.conclusion == 'success'
run: |
git config author.name Cheng-Hung Tsai
git config author.email chenghung.tsai@email.ucr.edu
git config committer.name GitHub Actions
git config committer.email actions@github.com
git add README.md
git commit -m "Update version in README.md"
git tag --annotate v${{ steps.tag.outputs.version }} -m "Version bump to v${{ steps.tag.outputs.version }}" --force
git push
git push --tags --force
# - name: Check version in pyproject.toml
# id: pyproject
# run: |
# cap=$(grep -oP '^version = "\K\d+\.\d+\.\d+[^"]*' pyproject.toml)
# echo "version=$cap" >> "$GITHUB_OUTPUT"

publish_release:
runs-on: ubuntu-latest
needs: version_check
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
# - name: Substitute version in README.md
# if: ${{ steps.readme.outputs.version != steps.tag.outputs.version }}
# id: sub_readme
# run: sed -i 's/${{ steps.repo.outputs.repo_name }}-${{ steps.readme.outputs.version }}/${{ steps.repo.outputs.repo_name }}-${{ steps.tag.outputs.version }}/g' README.md

- name: Release
uses: docker://antonyurchenko/git-release:v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: build/*.zip
# - name: Substitute version in pyproject.toml
# if: ${{ steps.pyproject.outputs.version != steps.tag.outputs.version }}
# id: sub_pyproject
# run: sed -i 's/^version = "${{ steps.pyproject.outputs.version }}"/version = "${{ steps.tag.outputs.version }}"/' pyproject.toml

# - name: Push changes
# if: steps.sub_readme.conclusion == 'success' && steps.sub_pyproject.conclusion == 'success'
# run: |
# git config author.name Cheng-Hung Tsai
# git config author.email chenghung.tsai@email.ucr.edu
# git config committer.name GitHub Actions
# git config committer.email actions@github.com
# git add .
# git commit -m "Update version in README.md"
# git tag --annotate v${{ steps.tag.outputs.version }} -m "Version bump to v${{ steps.tag.outputs.version }}" --force
# git push
# git push --tags --force

# publish_release:
# runs-on: ubuntu-latest
# needs: version_check
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# ref: main

# - name: Release
# uses: docker://antonyurchenko/git-release:v5
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# args: build/*.zip
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "phyling"
version = "2.0.0-alpha1"
version = "2.0.0-beta"
authors = [
{ name="Jason Stajich", email="jasonstajich.phd@gmail.com" },
{ name="Cheng-Hung Tsai", email="chenghung.tsai@email.ucr.edu" },
Expand Down

0 comments on commit 6e9c476

Please sign in to comment.