Skip to content

Commit

Permalink
ci: cleaner release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
shakefu committed Dec 2, 2023
1 parent deefba4 commit e5e7c25
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 32 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,45 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.event.number }}
cancel-in-progress: true

jobs:
preview:
name: Release preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Generate notes
id: notes
uses: open-turo/actions-release/semantic-release@v4
with:
branches: ${{ github.head_ref }}
override-github-ref-name: ${{ github.head_ref }}
dry-run: true
ci: false
- name: Find Comment
uses: peter-evans/find-comment@v2
id: find
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: release-notes-preview
- name: Comment preview
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.find.outputs.comment-id }}
issue-number: ${{ github.event.number }}
edit-mode: replace
body: |
<!-- release-notes-preview -->
## Release notes preview
${{ steps.notes.outputs.new-release-notes }}
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
50 changes: 18 additions & 32 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
push:
branches: [main]

concurrency:
group: release

jobs:
ci:
name: CI
Expand Down Expand Up @@ -32,46 +35,29 @@ jobs:
run: poetry install
- name: Find version
id: version
uses: cycjimmy/semantic-release-action@v3
uses: open-turo/actions-release/semantic-release@v4
with:
dry_run: true
branches: |
["main"]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
# branches: ${{ github.head_ref }}
# override-github-ref-name: ${{ github.head_ref }}
dry-run: true
ci: false
- name: Release check
if: steps.version.outputs.new-release-published != 'true'
run: exit 1
- name: Update version
if: steps.version.outputs.new_release_published == 'true'
shell: bash
run: |
# Use poetry to bump the version in pyproject.toml
poetry version "${{ steps.version.outputs.new_release_version }}"
EMAIL="[email protected]"
NAME="Jake Alheid"
# Set our git config for pushing
git config user.email "$EMAIL"
git config user.name "$NAME"
# Commit the bumped project version with a non-semver chore: commit message
git add pyproject.toml
git --no-pager diff --staged
git commit \
--author="$NAME <$EMAIL>" \
-m "chore: release ${{ steps.version.outputs.new_release_version }}" \
-m "[skip actions]"
git push || { echo "::error:: Failed to push version update for pyproject.toml, check your github-token permissions, or branch protections."; exit 1; }
# Nice logging, generate success exit code from this run step
echo "::notice::Version successfully updated in pyproject.toml to ${{ steps.version.outputs.new_release_version }}."
run: poetry version "${{ steps.version.outputs.new-release-version }}"
- name: Commit & push version
uses: actions-js/push@master
with:
message: "chore: ${{ steps.version.outputs.new-release-version }} [skip actions]"
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Poetry build
run: poetry build
- name: Publish to PyPI
if: steps.version.outputs.new_release_published == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
- name: Release
if: steps.version.outputs.new_release_published == 'true'
uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit e5e7c25

Please sign in to comment.