release 1.6.2 (#167) #52
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
name: publish-to-pypi | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish-to-pypi: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Install dependencies | |
run: npm install @iarna/toml | |
- name: Check for version changes | |
id: check_version | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const fs = require('fs'); | |
const execSync = require('child_process').execSync; | |
const toml = require('@iarna/toml'); | |
const current = fs.readFileSync('pyproject.toml', 'utf8'); | |
execSync('git checkout HEAD^1 pyproject.toml'); | |
const previous = fs.readFileSync('pyproject.toml', 'utf8'); | |
execSync('git checkout HEAD pyproject.toml'); | |
const currentVersion = toml.parse(current).tool.poetry.version; | |
const previousVersion = toml.parse(previous).tool.poetry.version; | |
const versionChanged = currentVersion !== previousVersion; | |
if (versionChanged) { | |
console.log(`version changed from ${previousVersion} to ${currentVersion}`); | |
return currentVersion; | |
} else { | |
console.log(`version did not change from ${previousVersion}`); | |
} | |
- name: Install Poetry | |
if: ${{ steps.check_version.outputs.result }} | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.5.1 | |
- name: Build and publish | |
if: ${{ steps.check_version.outputs.result }} | |
run: | | |
echo "Building version ${{ steps.check_version.outputs.result }} ..." | |
poetry build | |
echo "Publishing ..." | |
poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }} |