doc: Add directions for using dev containers (#237) #46
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: 🆙 Release | |
concurrency: release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release-file-check: | |
name: Get information about release | |
runs-on: ubuntu-latest | |
outputs: | |
changelog: ${{ steps.release-check.outputs.changelog }} | |
status: ${{ steps.release-check.outputs.release_status }} | |
change_type: ${{ steps.release-check.outputs.change_type }} | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Release file check | |
uses: ./.github/release-check-action | |
id: release-check | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: release-file-check | |
if: ${{ needs.release-file-check.outputs.status == 'OK' }} | |
outputs: | |
version: ${{ steps.get-version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install deps | |
run: | | |
python -m pip install pip --upgrade | |
pip install poetry | |
pip install githubrelease | |
pip install autopub | |
pip install httpx | |
- name: Check if we should release | |
id: check_release | |
run: | | |
set +e | |
echo ::set-output name=release::$(autopub check) | |
- name: Publish | |
if: steps.check_release.outputs.release == '' | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }} | |
autopub prepare | |
poetry build | |
autopub commit | |
autopub githubrelease | |
poetry publish --username __token__ | |
- name: Get project version | |
id: get-version | |
shell: python | |
run: | | |
import os | |
from pathlib import Path | |
from autopub.base import get_project_version | |
with Path(os.environ["GITHUB_OUTPUT"]).open('a') as f: | |
f.write(f"version={get_project_version()}\n") | |
get-contributor-info: | |
name: Get PR info | |
runs-on: ubuntu-latest | |
needs: release-file-check | |
if: ${{ needs.release-file-check.outputs.status == 'OK' }} | |
outputs: | |
contributor-username: ${{ steps.get-info.outputs.contributor-username }} | |
pr-number: ${{ steps.get-info.outputs.pr-number }} | |
steps: | |
- name: Get PR info | |
id: get-info | |
uses: strawberry-graphql/get-pr-info-action@v6 | |
update-release-on-github: | |
name: Update release on github | |
runs-on: ubuntu-latest | |
needs: [release-file-check, get-contributor-info, release] | |
if: ${{ needs.release-file-check.outputs.status == 'OK' }} | |
steps: | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: pip install httpx | |
- name: Update Github Release | |
shell: python | |
run: | | |
import os | |
import httpx | |
tag = os.environ["TAG"] | |
contributor_username = os.environ["CONTRIBUTOR_USERNAME"] | |
pr_number = os.environ["PR_NUMBER"] | |
response = httpx.get( | |
url=f"https://api.github.com/repos/strawberry-graphql/strawberry-sqlalchemy/releases/tags/{tag}", | |
headers={ | |
"Accept": "application/vnd.github.v3+json", | |
}, | |
) | |
response.raise_for_status() | |
data = response.json() | |
release_id = data["id"] | |
release_body = data["body"].strip() | |
release_footer = f""" | |
Releases contributed by @{contributor_username} via #{pr_number} | |
""".strip() | |
updated_release_body = f"{release_body}\n\n{release_footer}" | |
response = httpx.patch( | |
url=f"https://api.github.com/repos/strawberry-graphql/strawberry-sqlalchemy/releases/{release_id}", | |
json={"body": updated_release_body}, | |
headers={ | |
"Accept": "application/vnd.github.v3+json", | |
"Authorization": f"token {os.environ['GITHUB_TOKEN']}", | |
}, | |
) | |
response.raise_for_status() | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
TAG: ${{ needs.release.outputs.version }} | |
CONTRIBUTOR_USERNAME: ${{ needs.get-contributor-info.outputs.contributor-username }} | |
PR_NUMBER: ${{ needs.get-contributor-info.outputs.pr-number }} |