python-tuf/.github/workflows/specification-version.yml
dependabot[bot] 38b5e07f62
build(deps): bump actions/checkout from 2.4.0 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](ec3a7ce113...a12a3943b4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 10:21:30 +00:00

65 lines
2.5 KiB
YAML

name: Specification version check
on:
schedule:
- cron: '0 13 * * *'
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
check-spec-version:
name: Open an issue when spec version bumps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
- uses: actions/setup-python@0ebf233433c08fb9061af664d501c3f3ff0e9e20
- name: Get supported version
id: get-version
run: |
python3 -m pip install -e .
script="from tuf.api.metadata import SPECIFICATION_VERSION; \
print(f\"v{'.'.join(SPECIFICATION_VERSION)}\")"
ver=$(python3 -c "$script")
echo "::set-output name=version::$ver"
- name: Open issue (if needed)
uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e
with:
script: |
const release = await github.rest.repos.getLatestRelease({
owner: "theupdateframework",
repo: "specification"
});
const spec_version = release.data.tag_name
const supported_version = "${{ steps.get-version.outputs.version }}"
if (spec_version != supported_version) {
console.log(
"Specification (" + spec_version + ") version does not matches with python-tuf supported (" +
supported_version + ") version."
)
const repo = context.repo.owner + "/" + context.repo.repo
const issues = await github.rest.search.issuesAndPullRequests({
q: "specification+has+new+version+in:title+state:open+type:issue+repo:" + repo,
})
if (issues.data.total_count > 0) {
console.log("Issue is already open, not creating.")
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "specification has new version",
body: "It seems specification " +
"(https://github.com/theupdateframework/specification/blob/master/tuf-spec.md) " +
"has new version. \n" +
"Please review the version."
})
console.log("New issue created.")
}
} else {
console.log(
"Specification (" + spec_version + ") version matches with python-tuf supported (" +
supported_version + ") version."
)
}