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

Lifei/fix GitHub workflow triggers #27

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
40 changes: 38 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: CI

on:
pull_request:
branches: [main]
branches:
- main
push:
branches:
- main

jobs:
build:
Expand All @@ -19,4 +23,36 @@ jobs:

- name: Run tests
run: |
uv run pytest tests -m 'not integration'
uv run pytest tests -m 'not integration'

create_tag:
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be run on the release workflow - not ci? ci just for testing?

Copy link
Collaborator Author

@lifeizhou-ap lifeizhou-ap Aug 29, 2024

Choose a reason for hiding this comment

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

I can move this on the release workflow. and the release workflow depends on the ci workflow and only run on the main branch. Therefore it would be better.

because currently in my PR it shows like this (although the create tag job is skipped). It would be good to move the create tag on the release workflow.
Screenshot 2024-08-29 at 8 44 35 PM

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've pushed a commit to move the create_tag job to the pypi_release workflow now

runs-on: ubuntu-latest
needs: build
if: ${{ github.ref == 'refs/heads/main' }}

steps:
- uses: actions/checkout@v4

- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Source Cargo Environment
run: source $HOME/.cargo/env

- name: Build with UV
run: uvx --from build pyproject-build --installer uv

- name: Check tag exists
run: |
dist_file_name=$(cd dist && ls goose-ai*.tar.gz)
./scripts/check_tag_exists.sh $dist_file_name
env:
GITHUB_ENV: $GITHUB_ENV

- name: Create tag if it doesn't exist
if: env.tag_version != ''
run: |
git tag "v$tag_version"
git push origin "v$tag_version"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/pypi_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh
Expand Down
18 changes: 18 additions & 0 deletions scripts/check_tag_exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
dist_file_name="$1"
echo "dist_file_name=$dist_file_name"

version=$(echo "$dist_file_name" | sed -E 's/^goose-ai-([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz$/\1/')
echo "version=$version"

if [ "$version" != "$dist_file_name" ]; then
git fetch --tags
tag_exists=$(git tag --list "v$version")
echo "tag_exists=$tag_exists"
fi
if [ -z "$tag_exists" ]; then
echo "version $version is not tagged yet"
echo "tag_version=$version" >> "$GITHUB_ENV"
else
echo "Tag exists"
fi