Debug auth #22
This file contains hidden or 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
name: Versioning & Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
pre-checks: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Validate Workflow Trigger | |
run: echo "Starting the release workflow..." | |
check-tests: | |
runs-on: ubuntu-latest | |
needs: pre-checks | |
steps: | |
- name: Download All Test Results | |
uses: actions/download-artifact@v4 | |
with: | |
path: test-results # Store test results here | |
- name: Aggregate Test Results | |
id: aggregate_tests | |
run: | | |
FAILED_TESTS=0 | |
if [ -d "test-results" ]; then | |
for file in test-results/*/test_result_*; do | |
TEST_STATUS=$(cat "$file") | |
if [[ "$TEST_STATUS" == "failure" ]]; then | |
FAILED_TESTS=$((FAILED_TESTS + 1)) | |
fi | |
done | |
fi | |
echo "TOTAL_FAILED_TESTS=$FAILED_TESTS" >> $GITHUB_ENV | |
echo "Failed tests: $FAILED_TESTS" | |
- name: Read Commit Message | |
id: commit_msg | |
run: echo "COMMIT_MSG=$(git log -1 --pretty=%B)" >> $GITHUB_ENV | |
- name: Skip Release if Any Test Failed (Unless Forced) | |
if: env.TOTAL_FAILED_TESTS != '0' && !contains(env.COMMIT_MSG, 'FORCE-RELEASE') | |
run: | | |
echo "Tests failed ($TOTAL_FAILED_TESTS jobs failed). Skipping release." | |
exit 1 | |
versioning: | |
needs: check-tests | |
runs-on: ubuntu-latest | |
if: success() # Only runs if all tests passed | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Read Current Version | |
id: get_version | |
run: | | |
VERSION=$(grep -m 1 '^__version__ =' cli_monitor.py | awk -F'=' '{print $2}' | sed 's/[^0-9.]//g') | |
echo "CURRENT_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Determine Version Increment | |
id: version_bump | |
run: | | |
CURRENT_VERSION=${{ env.CURRENT_VERSION }} | |
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1) | |
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2) | |
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3) | |
COMMIT_MSG=$(git log -1 --pretty=%B) | |
if [[ "$COMMIT_MSG" == *"MAJOR"* ]]; then | |
MAJOR=$((MAJOR + 1)) | |
MINOR=0 | |
PATCH=0 | |
elif [[ "$COMMIT_MSG" == *"MINOR"* ]]; then | |
MINOR=$((MINOR + 1)) | |
PATCH=0 | |
elif [[ "$COMMIT_MSG" == *"PATCH"* ]]; then | |
PATCH=$((PATCH + 1)) | |
fi | |
NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
echo "Version updated to $NEW_VERSION" | |
- name: Update Version in `cli_monitor.py` | |
run: sed -i "s/^__version__ = .*/__version__ = \"${{ env.NEW_VERSION }}\"/" cli_monitor.py | |
- name: Debug GitHub Authentication | |
run: | | |
git remote -v | |
- name: Commit & Push Version Update | |
env: | |
GH_PAT: ${{ secrets.GH_PAT }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions@users.noreply.github.com" | |
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/Dimos082/cli-monitor.git | |
git add cli_monitor.py | |
git commit -m "chore: bump version to ${{ env.NEW_VERSION }}" || echo "No changes to commit" | |
git push origin main | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ env.NEW_VERSION }} | |
name: Release v${{ env.NEW_VERSION }} | |
body: "Automated release for version ${{ env.NEW_VERSION }}" | |
draft: false | |
prerelease: false | |
files: cli_monitor.py |