Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: improve beta bump and release handling #674

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@ jobs:
if [ "${{ steps.bump-type.outputs.type }}" = "stable" ]; then
COMMAND="hatch run bump"
else
# For beta, only proceed if current version is not beta
if [ "${{ steps.current-version.outputs.is_beta }}" = "true" ]; then
echo "Current version is already beta, skipping bump"
echo "bumped=false" >> $GITHUB_OUTPUT
exit 0
fi
# For beta, we should always run the bump
COMMAND="hatch run beta-bump"
fi
# Execute the command
if $COMMAND; then
echo "bumped=true" >> $GITHUB_OUTPUT
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: cd

on:
push:
tags:
# Stable releases (1.2.3)
- 'v?[0-9]+.[0-9]+.[0-9]+'
# Beta releases (1.2.3b0)
- 'v?[0-9]+.[0-9]+.[0-9]+b[0-9]+'

jobs:
ci:
uses: ./.github/workflows/ci.yml

build:
needs: [ci]
uses: ./.github/workflows/reusable-build.yml

# TODO: Test generated artifacts before releasing and publish
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Are you planning on following on the tests?


release:
needs: [ci, build]
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download all artifacts
uses: actions/download-artifact@v4

- name: Get version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Tag version: $VERSION"

- name: Generate release notes
id: release_notes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^)
NOTES=$(git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)")
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
echo "## What's Changed" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create GitHub Release
id: create_release
uses: softprops/[email protected]
with:
name: Version ${{ steps.get_version.outputs.version }}
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
files: |
safety-linux/safety
safety-windows/safety.exe
safety-macos/safety
dist/*
prerelease: ${{ contains(steps.get_version.outputs.version, 'b') }}

publish:
needs: [release]
runs-on: ubuntu-24.04
environment:
name: pypi
url: https://pypi.org/p/safety
permissions:
id-token: write
steps:
- name: Download dist artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
print-hash: true
3 changes: 2 additions & 1 deletion .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ on:
type: string
default: "3.12"
bump-command:
required: true
required: false
type: string
default: ""
branch-name:
required: false
type: string
Expand Down
Loading