Skip to content

Commit 026948a

Browse files
authored
Token for access, force-release feature and check for test passing added
1 parent d0b4fb4 commit 026948a

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,33 @@ name: Versioning & Release
33
on:
44
push:
55
branches:
6-
- main # Only auto-increment when committing to main
6+
- main
77

88
jobs:
9+
check-tests:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Get Test Results
14+
uses: actions/download-artifact@v4
15+
with:
16+
name: TESTS_PASSED
17+
path: $GITHUB_ENV
18+
19+
- name: Read Commit Message
20+
id: commit_msg
21+
run: echo "COMMIT_MSG=$(git log -1 --pretty=%B)" >> $GITHUB_ENV
22+
23+
- name: Skip Release if Tests Failed (Unless Forced)
24+
if: env.TESTS_PASSED == 'failure' && !contains(env.COMMIT_MSG, 'FORCE-RELEASE')
25+
run: |
26+
echo "Tests failed. Skipping release."
27+
exit 1
28+
929
versioning:
30+
needs: check-tests
1031
runs-on: ubuntu-latest
32+
if: success() # Only runs if check-tests job passes
1133

1234
steps:
1335
- name: Checkout Repository
@@ -16,7 +38,7 @@ jobs:
1638
- name: Read Current Version
1739
id: get_version
1840
run: |
19-
VERSION=$(grep '^__version__ =' cli_monitor.py | cut -d '"' -f2)
41+
VERSION=$(grep '^__version__ =' cli_monitor.py | cut -d '"' -f2)
2042
echo "CURRENT_VERSION=$VERSION" >> $GITHUB_ENV
2143
2244
- name: Determine Version Increment
@@ -48,12 +70,14 @@ jobs:
4870
run: sed -i "s/^__version__ = .*/__version__ = \"${{ env.NEW_VERSION }}\"/" cli_monitor.py
4971

5072
- name: Commit & Push Version Update
73+
env:
74+
GH_PAT: ${{ secrets.GH_PAT }}
5175
run: |
5276
git config --global user.name "github-actions[bot]"
5377
git config --global user.email "github-actions@users.noreply.github.com"
5478
git add cli_monitor.py
5579
git commit -m "chore: bump version to ${{ env.NEW_VERSION }}"
56-
git push
80+
git push https://Dimos082:${GH_PAT}@github.com/Dimos082/cli-monitor.git
5781
5882
- name: Create GitHub Release
5983
uses: softprops/action-gh-release@v2

0 commit comments

Comments
 (0)