Merge pull request #145 from datalad/dependabot/github_actions/codeco… #34
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: Auto-release on PR merge | |
on: | |
# ATM, this is the closest trigger to a PR merging | |
push: | |
branches: | |
- master | |
jobs: | |
auto-release: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" | |
outputs: | |
auto-version: ${{ steps.auto-version.outputs.version }} | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download latest auto | |
run: | | |
auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/latest | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')" | |
wget -O- "$auto_download_url" | gunzip > ~/auto | |
chmod a+x ~/auto | |
- name: Check whether a release is due | |
id: auto-version | |
run: | | |
version="$(~/auto version)" | |
echo "version=$version" >> "$GITHUB_OUTPUT" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create release | |
run: ~/auto shipit | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
pypi: | |
runs-on: ubuntu-latest | |
needs: auto-release | |
if: "needs.auto-release.outputs.auto-version != ''" | |
steps: | |
# By default, actions/checkout will checkout the commit that that was | |
# pushed to master and triggered the workflow, but this does not include | |
# the commit & tag created by `auto`. In order to get that, we need to | |
# look up the tag for the latest release. | |
- name: Get tag of latest release | |
id: latest-release | |
run: | | |
latest_tag="$(curl -fsSL https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq -r .tag_name)" | |
echo "tag=$latest_tag" >> "$GITHUB_OUTPUT" | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ steps.latest-release.outputs.tag }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install build & twine | |
run: python -m pip install build twine | |
- name: Build | |
run: python -m build | |
- name: Upload | |
run: twine upload dist/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
# vim:set et sts=2: |