-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 changed file
with
30 additions
and
0 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 |
---|---|---|
|
@@ -19,7 +19,37 @@ jobs: | |
needs: lint | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check for version change in pyproject.toml | ||
id: check_version | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const payload = context.payload; | ||
const headCommit = payload.commits[payload.commits.length - 1]; | ||
const changedFiles = headCommit.modified.concat(headCommit.added).concat(headCommit.removed); | ||
const isVersionChanged = changedFiles.includes('pyproject.toml'); | ||
if (!isVersionChanged) { | ||
console.log("No change in pyproject.toml"); | ||
return false; | ||
} | ||
const fs = require('fs'); | ||
const content = fs.readFileSync('./pyproject.toml', 'utf8'); | ||
const versionRegex = /version = "(\S+)"/; | ||
const match = versionRegex.exec(content); | ||
if (match) { | ||
core.setOutput('new_version', match[1]); | ||
console.log(`Version changed to ${match[1]}`); | ||
return true; | ||
} else { | ||
console.log("Version line not found or unchanged"); | ||
return false; | ||
} | ||
result-encoding: string | ||
- name: Publish Package | ||
if: steps.check_version.outputs.new_version | ||
uses: JRubics/[email protected] | ||
with: | ||
pypi_token: ${{ secrets.PYPI_API_TOKEN }} |