Skip to content

ci: tests: build: Fix loop to sleep when waiting #15

ci: tests: build: Fix loop to sleep when waiting

ci: tests: build: Fix loop to sleep when waiting #15

Workflow file for this run

name: Publish Release
on:
push:
tags:
- '*'
workflow_dispatch: {}
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache
id: pip-cache
run: |
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
- name: pip cache
uses: actions/cache@v1
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U build
- name: Build
run: |
python -m build .
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist
pypi:
name: PyPi
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Get pip cache
id: pip-cache
run: |
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
- name: pip cache
uses: actions/cache@v1
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U twine
- name: Release
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m twine upload dist/*
github:
name: GitHub
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Upload wheel
env:
GH_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
tag=$(echo "${{ github.ref }}" | sed -e 's/.*\///g')
cd dist
wheel=$(echo *.whl)
notes=$(curl \
--header "Accept: application/vnd.github.v3+json" \
--header "Authorization: Bearer ${GH_ACCESS_TOKEN}" \
--url "https://api.github.com/repos/${{ github.repository }}/releases/generate-notes" \
--data "{\"tag_name\": \"${tag}\"}")
echo "${notes}"
# TODO Update release body with notes, need to JSON escape
# https://docs.github.com/en/rest/reference/releases#update-a-release
id=$(curl \
--header "Accept: application/vnd.github.v3+json" \
--header "Authorization: Bearer ${GH_ACCESS_TOKEN}" \
--url "https://api.github.com/repos/${{ github.repository }}/releases/tags/${tag}" |
grep '"id"' |
head -n 1 |
sed -e 's/.*"id": //' -e 's/,//')
echo "release id: ${id}"
curl --request POST \
--url "https://uploads.github.com/repos/${{ github.repository }}/releases/${id}/assets?name=${wheel}&access_token=${GH_ACCESS_TOKEN}" \
--header "Authorization: Bearer ${GH_ACCESS_TOKEN}" \
--header "Content-Type: application/octet-stream" \
--data-binary @"${wheel}" \
--fail