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

Move to automated version release when intended #12

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all 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
32 changes: 12 additions & 20 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,19 @@ on:
- main

jobs:
# Validate that the version.txt file was incremented to ensure release process passes after merge to main
check_version_increment:
# Checks for changes in version.txt (used for release job)
changes:
runs-on: ubuntu-latest
# This job will only run for pull requests, not for pushes to main
if: github.event_name == 'pull_request'
outputs:
version_changed: ${{ steps.filter.outputs.version_changed }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
fetch-depth: 0 # Ensures we fetch all history for all branches
- name: Check if version was incremented
run: |
NEW_VERSION=$(cat cover_agent/version.txt)
git fetch origin main
git checkout origin/main -- cover_agent/version.txt
OLD_VERSION=$(cat cover_agent/version.txt)
if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
echo "ERROR: The version number in version.txt must be incremented."
echo "Version on origin/main: $OLD_VERSION"
echo "Version on ${{ github.head_ref }}: $NEW_VERSION"
exit 1
fi
filters: |
version_changed:
- 'cover_agent/version.txt'

test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -92,8 +84,8 @@ jobs:
path: dist/cover-agent-${{ matrix.os }}*

release:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [build, changes]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changes.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
Loading