-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
194 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Automated Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check-and-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Get the latest release version | ||
- name: Get latest release version | ||
id: get_latest_release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
latest_release=$(gh release list --limit 1 --json tagName --jq '.[0].tagName' || echo "v0.0.0") | ||
echo "latest_release=${latest_release}" >> $GITHUB_ENV | ||
# Extract version from _RELEASE_VERSION constant in main.py | ||
- name: Extract version from main.py | ||
id: get_submitted_version | ||
run: | | ||
submitted_version=$(grep '_RELEASE_VERSION' src/backend/main.py | sed -E 's/.*"([^"]+)".*/\1/') | ||
echo "submitted_version=${submitted_version}" >> $GITHUB_ENV | ||
# Check if new version is greater | ||
- name: Check if new version is greater | ||
id: check_version | ||
run: | | ||
latest_version_number=$(echo "$latest_release" | sed 's/^v//') | ||
submitted_version_number=$(echo "$submitted_version" | sed 's/^v//') | ||
# Get major, minor, and patch from the versions | ||
IFS='.' read -r l_major l_minor l_patch <<<"$latest_version_number" | ||
IFS='.' read -r f_major f_minor f_patch <<<"$submitted_version_number" | ||
# Compare major, minor, and patch versions | ||
if [ "$f_major" -gt "$l_major" ] || | ||
([ "$f_major" -eq "$l_major" ] && [ "$f_minor" -gt "$l_minor" ]) || | ||
([ "$f_major" -eq "$l_major" ] && [ "$f_minor" -eq "$l_minor" ] && [ "$f_patch" -gt "$l_patch" ]); then | ||
echo "new_version_needed=true" >> $GITHUB_ENV | ||
echo "NEED TO CREATE A NEW RELEASE." | ||
else | ||
echo "new_version_needed=false" >> $GITHUB_ENV | ||
echo "NO NEED TO CREATE A NEW RELEASE." | ||
exit 0 | ||
fi | ||
# Create a new release if the version is greater | ||
- name: Create new release | ||
if: env.new_version_needed == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
release_date=$(date +'%Y-%m-%d') | ||
release_title="${release_date} (${submitted_version})" | ||
description="### Full Changelog: https://github.com/${GITHUB_REPOSITORY}/compare/${latest_release}...${submitted_version}" | ||
latest_release_date=$(gh release view "${latest_release}" --json createdAt --jq '.createdAt') | ||
changelog=$(gh pr list --state merged --base main --search "merged:>$latest_release_date" --json title,number,url,author --jq '.[] | "- PR #" + (.number|tostring) + " by @" + (.author.login) + ": " + .title') | ||
if [[ -z "$changelog" ]]; then | ||
echo "No pull requests found since the last release." | ||
changelog="No pull requests found since the last release." | ||
fi | ||
description="## What's Changed:\n${changelog}\n${description}" | ||
echo "Creating release with title: $release_title" | ||
gh release create "${submitted_version}" \ | ||
--title "$release_title" \ | ||
--notes "$(echo -e "$description")" | ||
echo "Release created successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
src/backend/database_models/seeders/deployments_models_seed.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from sqlalchemy import text | ||
from sqlalchemy.orm import Session | ||
|
||
from backend.database_models import Organization | ||
|
||
|
||
def seed_default_organization(op): | ||
""" | ||
Seed default organization. | ||
""" | ||
# Previously we would seed the default deployments and models here. We've changed this | ||
# behaviour during a refactor of the deployments module so that deployments and models | ||
# are inserted when they're first used. This solves an issue where seed data would | ||
# sometimes be inserted with invalid config data. | ||
|
||
_ = Session(op.get_bind()) | ||
|
||
# Seed default organization | ||
sql_command = text( | ||
""" | ||
INSERT INTO organizations ( | ||
id, name, created_at, updated_at | ||
) | ||
VALUES ( | ||
:id, :name, now(), now() | ||
) | ||
ON CONFLICT (id) DO NOTHING; | ||
""" | ||
).bindparams( | ||
id="default", | ||
name="Default Organization", | ||
) | ||
op.execute(sql_command) | ||
|
||
|
||
def delete_default_organization(op): | ||
""" | ||
Delete default organization. | ||
""" | ||
session = Session(op.get_bind()) | ||
session.query(Organization).filter_by(id="default").delete() | ||
session.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[pytest] | ||
env = | ||
DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres | ||
DATABASE_URL=postgresql://postgres:postgres@localhost:5433 | ||
filterwarnings = | ||
ignore::UserWarning:pydantic.* | ||
ignore::DeprecationWarning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.