Skip to content

Commit

Permalink
Extract release process into separate workflow (#1839)
Browse files Browse the repository at this point in the history
* Extract release process into separate workflow

* Remove workflow_dispatch trigger
  • Loading branch information
mattt authored Jul 31, 2024
1 parent 592f768 commit 36d019e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 43 deletions.
44 changes: 1 addition & 43 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
tags:
- "**"
- "v*"
pull_request:
branches:
- main
Expand Down Expand Up @@ -93,45 +93,3 @@ jobs:
python -m uv pip install '.[dev]'
- name: Test
run: make test-integration

release:
needs:
- test-go
- test-python
- test-integration
if: startsWith(github.ref, 'refs/tags/v')
outputs:
cog_version: ${{ steps.build-python-package.outputs.version }}
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: make cog
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Python package
id: build-python-package
run: |
# clean package built for go client
rm -rf dist
# install build
pip install build
# build package
python -m build --wheel
# set output
echo "version=$(ls dist/ | cut -d- -f2)" >> $GITHUB_OUTPUT
- name: Push Python package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: dist
70 changes: 70 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release

on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

jobs:
check-tag:
name: "Check Tag"
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
is-release: ${{ steps.check-tag.outputs.is-release }}
steps:
- name: Check if commit has a version tag
id: check-tag
run: |
if [[ ${{ github.event.workflow_run.head_branch }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is-release=true" >> $GITHUB_OUTPUT
else
echo "is-release=false" >> $GITHUB_OUTPUT
fi
release-cli:
name: "CLI"
needs: check-tag
if: needs.check-tag.outputs.is-release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: make cog
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-python-package:
name: "Python Package"
needs: check-tag
if: needs.check-tag.outputs.is-release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Build Python package
run: |
pip install build
python -m build --wheel
- name: Push Python package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: dist

0 comments on commit 36d019e

Please sign in to comment.