Skip to content

Commit

Permalink
fixed github workflow triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeizhou-ap committed Aug 29, 2024
1 parent f696a4d commit 2e053b8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
34 changes: 33 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,36 @@ jobs:

- name: Run tests
run: |
uv run pytest tests -m 'not integration'
uv run pytest tests -m 'not integration'
create_tag:
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 }}
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

0 comments on commit 2e053b8

Please sign in to comment.