Retain state (#66) #9
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: Push to Main | ||
on: | ||
workflow_dispatch: {} | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
version-check: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_version: ${{ steps.check-version.outputs.new_version }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check Version | ||
id: check-version | ||
run: | | ||
version=$(grep -P -o 'version = "\d+\.\d+\.\d+"' pyproject.toml | grep -P -o '\d+\.\d+\.\d+') | ||
tags=$(git tag -l '*.*.*') | ||
match=$(echo ${tags} | grep -w -c ${version} | cat) | ||
if [ "${match}" == "0" ]; then | ||
echo "new_version=${version}" >> "${GITHUB_OUTPUT}" | ||
else | ||
echo "new_version=false" >> "${GITHUB_OUTPUT}" | ||
fi | ||
python-package: | ||
runs-on: ubuntu-latest | ||
needs: version-check | ||
if: ${{ needs.version-check.outputs.new_version != 'false' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
- name: Install Build Tools | ||
run: pip install --upgrade build twine | ||
- name: Build | ||
run: python3 -m build | ||
- name: Upload | ||
run: | | ||
python3 -m twine upload \ | ||
--verbose --non-interactive \ | ||
--username __token__ --password ${{ secrets.PYPI_TOKEN }} \ | ||
dist/* | ||
- name: Tag | ||
uses: mathieudutour/github-tag-action@v6.1 | ||
with: | ||
github_token: "${{ secrets.GITHUB_TOKEN }}" | ||
custom_tag: "${{ needs.version-check.outputs.new_version }}" | ||
tag_prefix: "" | ||
default_bump: false | ||
rock: | ||
uses: canonical/observability/.github/workflows/build-rock.yaml@main | ||
Check failure on line 58 in .github/workflows/push-main.yaml GitHub Actions / .github/workflows/push-main.yamlInvalid workflow file
|
||
needs: python-package | ||
secrets: inherit | ||
with: | ||
rock-name: cos-alerter | ||
tag-minor: true |