Skip to content

chore(deps): update minor updates #793

chore(deps): update minor updates

chore(deps): update minor updates #793

Workflow file for this run

name: ci
on:
push:
branches:
- main
- renovate/*
tags:
- v*
pull_request:
branches:
- main
- dev/*
jobs:
test:
runs-on: ubuntu-latest
services:
mongo:
image: mongo:6
ports:
- 27017:27017
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: '3.10'
- name: Install dependencies (with all extras)
run: |
python -m pip install --upgrade poetry
poetry install --all-extras
- run: poetry run pytest
env:
MONGO_PORT: ${{ job.services.mongo.ports[27017] }}
DROPBOX_TOKEN: ${{ secrets.dropbox_token }}
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: '3.10.11'
- name: Install dependencies (with all extras)
run: |
python -m pip install --upgrade poetry
poetry install --all-extras
- run: poetry run mypy --namespace-packages -p ampel
check_version:
name: Tag version bump
runs-on: ubuntu-latest
# run only on pushes, not PRs
if: ${{ github.event_name == 'push' && github.base_ref == null }}
needs: [test, mypy]
outputs:
should_publish: ${{ steps.check.outputs.result }}
steps:
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 14
- run: npm install [email protected]
- name: Ensure tag for version bump
id: check
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
with:
script: |
const toml = require('toml')
async function getVersion(ref) {
try {
response = await github.rest.repos.getContent({
repo: context.repo.repo,
owner: context.repo.owner,
path: 'pyproject.toml',
ref: ref
});
return toml.parse(Buffer.from(response.data.content, 'base64').toString())
.tool
.poetry
.version;
} catch (exc) {
if (exc.name == 'HttpError' && exc.status == 404) {
return null;
} else {
throw exc;
}
}
}
after = await getVersion(context.payload.after);
ref = `refs/tags/v${after}`
is_main = context.payload.ref === `refs/heads/${context.payload.repository.default_branch}`
// a tag matching the version was just pushed
let release = context.payload.ref == ref;
if (release) {
console.log(`Tag v${after} pushed (${context.sha})`);
}
// the version on the default branch changed; create a tag
if (!release && is_main) {
before = await getVersion(context.payload.before);
if (before !== after) {
console.log(`Version bumped: ${before} -> ${after}`);
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref,
sha: context.sha
});
console.log(`Tag v${after} created (${context.sha})`);
release = true;
} catch (exc) {
// tag already existed
if (exc.name == 'HttpError' && exc.status == 422) {
console.log(`Skipping publish (tag v${after} already exists)`);
release = false;
} else {
throw exc;
}
}
} else {
console.log(`Skipping publish (version is still ${before})`);
}
} else if (!is_main) {
console.log(`Skipping publish (push to ${context.payload.ref} != refs/heads/${context.payload.repository.default_branch})`);
}
return release;
pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [check_version]
# NB: outputs are always strings; explicitly parse to get a boolean
if: ${{ fromJSON(needs.check_version.outputs.should_publish) }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: '3.10'
- name: Install poetry
run: |
python -m pip install --upgrade poetry
- name: Publish
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -n --build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.PYPI_TEST_API_TOKEN }}