From 596bfc8772466009db0b498b01a329a2715be979 Mon Sep 17 00:00:00 2001 From: Cullen Taylor Date: Tue, 28 Oct 2025 10:50:51 -0400 Subject: [PATCH] feat: release from tags instead of branch promotion * Removes release_prod.yaml and prod_patches_to_main.yaml workflows as they are no longer needed. * pypy.yaml workflow now triggers on semver tags instead of prod branch pushes. * new create_release_tag.yaml workflow will handle tag creation New release process: 1. Update version in pyproject.toml 2. Commit and merge to main 3. Trigger "Create Release Tag" workflow with the version number 4. Tag creation automatically triggers pypi deployment We can switch to tag creation on pyproject.toml version updates if we want, I just thought still having a human in the loop on when to push might be an easier transition. Signed-off-by: Cullen Taylor --- .github/workflows/create_release_tag.yaml | 62 +++++++++++++++++ .github/workflows/prod_patches_to_main.yaml | 73 -------------------- .github/workflows/pypi.yaml | 6 +- .github/workflows/release_prod.yaml | 74 --------------------- 4 files changed, 65 insertions(+), 150 deletions(-) create mode 100644 .github/workflows/create_release_tag.yaml delete mode 100644 .github/workflows/prod_patches_to_main.yaml delete mode 100644 .github/workflows/release_prod.yaml diff --git a/.github/workflows/create_release_tag.yaml b/.github/workflows/create_release_tag.yaml new file mode 100644 index 000000000..256c68834 --- /dev/null +++ b/.github/workflows/create_release_tag.yaml @@ -0,0 +1,62 @@ +name: Create Release Tag + +permissions: + contents: write + +on: + workflow_dispatch: + inputs: + version: + description: "Version to release (e.g., 1.2.3)" + required: true + type: string + +jobs: + create-tag: + runs-on: ubuntu-latest + steps: + - name: Checkout Main Branch + uses: actions/checkout@v4 + with: + ref: "main" + fetch-depth: 0 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + cache: "poetry" + + - name: Get Current Version + id: get_version + run: | + echo "CURRENT_VERSION=$(poetry version -s)" >> $GITHUB_ENV + + - name: Validate Version Match + run: | + if [ "${{ github.event.inputs.version }}" != "${{ env.CURRENT_VERSION }}" ]; then + echo "Error: Input version (${{ github.event.inputs.version }}) does not match pyproject.toml version (${{ env.CURRENT_VERSION }})" + echo "Please update the version in pyproject.toml first by running: poetry version ${{ github.event.inputs.version }}" + exit 1 + fi + + - name: Setup Git Config + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + + - name: Create and Push Tag + run: | + git tag -a "v${{ github.event.inputs.version }}" -m "Release version ${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + + - name: Create GitHub Release + run: | + gh release create "v${{ github.event.inputs.version }}" \ + --title "v${{ github.event.inputs.version }}" \ + --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/prod_patches_to_main.yaml b/.github/workflows/prod_patches_to_main.yaml deleted file mode 100644 index 7379b7d2e..000000000 --- a/.github/workflows/prod_patches_to_main.yaml +++ /dev/null @@ -1,73 +0,0 @@ -name: Bring Prod Hotfixes to Main - -permissions: - contents: write - pull-requests: write - -on: - workflow_dispatch: - inputs: - custom_branch_name: - description: 'Custom Branch Name (optional)' - required: false - default: '' - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout Prod Branch - uses: actions/checkout@v3 - with: - ref: 'prod' - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.11 - uses: actions/setup-python@v3 - with: - python-version: '3.11' - - - name: Get Application Version - id: get_version - run: | - echo "APP_VERSION=$(poetry version -s)" >> $GITHUB_ENV - - - name: Determine Branch Name - id: set_branch_name - run: | - if [ -z "${{ github.event.inputs.custom_branch_name }}" ]; then - echo "BRANCH_NAME=prod-${{ env.APP_VERSION }}-to-main" >> $GITHUB_ENV - else - echo "BRANCH_NAME=${{ github.event.inputs.custom_branch_name }}" >> $GITHUB_ENV - fi - - - name: Checkout Main Branch - uses: actions/checkout@v3 - with: - ref: 'main' - fetch-depth: 0 - - - name: Setup Git Config - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - - name: Create Main-Update Branch - run: | - git checkout -b ${{ env.BRANCH_NAME }} - - - name: Merge Prod into Main-Update - run: | - git merge --no-ff origin/prod - - - name: Push to GitHub - run: | - git push origin ${{ env.BRANCH_NAME }} - - - name: Create Pull Request - run: | - gh pr create --base main --head ${{ env.BRANCH_NAME }} --title "Merge Prod hotfixes into Main (${{env.BRANCH_NAME}})" --body "Merging hotfixes from Prod into Main, branch ${{ env.BRANCH_NAME }}." --label "internal" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index 5bbfde667..95d004c52 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -1,11 +1,11 @@ -# This worklfow pushes the ValidMind Library package to PyPI +# This workflow pushes the ValidMind Library package to PyPI when a tag is created name: Publish to PyPI on: push: - branches: - - prod + tags: + - 'v*.*.*' permissions: contents: read diff --git a/.github/workflows/release_prod.yaml b/.github/workflows/release_prod.yaml deleted file mode 100644 index d99e769f6..000000000 --- a/.github/workflows/release_prod.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: Create Prod Release - -permissions: - contents: write - pull-requests: write - -on: - workflow_dispatch: - inputs: - custom_branch_name: - description: "Custom Branch Name (optional)" - required: false - default: "" - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout Main Branch - uses: actions/checkout@v4 - with: - ref: "main" - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: "3.11" - cache: "poetry" - - - name: Get Application Version - id: get_version - run: | - echo "APP_VERSION=$(poetry version -s)" >> $GITHUB_ENV - - - name: Determine Branch Name - id: set_branch_name - run: | - if [ -z "${{ github.event.inputs.custom_branch_name }}" ]; then - echo "BRANCH_NAME=prod-${{ env.APP_VERSION }}" >> $GITHUB_ENV - else - echo "BRANCH_NAME=${{ github.event.inputs.custom_branch_name }}" >> $GITHUB_ENV - fi - - - name: Checkout Prod Branch - uses: actions/checkout@v4 - with: - ref: "prod" - fetch-depth: 0 - - - name: Setup Git Config - run: | - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - - name: Create Prod-Update Branch - run: | - git checkout -b ${{ env.BRANCH_NAME }} - - - name: Merge Main into Prod-Update - run: | - git merge --no-ff origin/main - - - name: Push to GitHub - run: | - git push origin ${{ env.BRANCH_NAME }} - - - name: Create Pull Request - run: | - gh pr create --base prod --head ${{ env.BRANCH_NAME }} --title "Merge Main into Prod (${{env.BRANCH_NAME}})" --body "Merging changes from Main into Prod, branch ${{ env.BRANCH_NAME }}." --label "internal" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}