-
Notifications
You must be signed in to change notification settings - Fork 54
82 lines (82 loc) · 3.86 KB
/
check-latest-spec-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Description:
# This is a reusable workflow that can be used by projects to keep track of
# new TUF specification releases. It automatically opens an issue to notify
# the project in case the released version is different from what the project
# states it supports.
#
# Usage:
# The following is an example of how to use the workflow.
#
# Create a yml file inside the project's ".github/workflows/" directory with the following content:
# on:
# schedule:
# - cron: "0 13 * * *"
# workflow_dispatch:
# name: Specification version check
# jobs:
# # Get the latest TUF specification release and open an issue (if needed)
# specification-bump-check:
# permissions:
# contents: read
# issues: write
# uses: theupdateframework/specification/.github/workflows/check-latest-spec-version.yml@master
# with:
# tuf-version: "v1.0.29" # Should be updated to the version the project supports either manually or extracted automatically. You can see how python-tuf did that as an example.
#
on:
workflow_call:
inputs:
tuf-version:
required: true
type: string
name: Get the latest TUF specification release and open an issue (if needed)
jobs:
check-spec-version:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |
const release = await github.rest.repos.getLatestRelease({
owner: "theupdateframework",
repo: "specification"
});
const latest_version = release.data.tag_name
const supported_version = "${{ inputs.tuf-version }}"
const repo = context.repo.owner + "/" + context.repo.repo
if (latest_version != supported_version) {
console.log(
"The latest TUF specification version (" + latest_version + ") does not match with the version that " + repo + " supports (" +
supported_version + ")"
)
const issues = await github.rest.search.issuesAndPullRequests({
q: "TUF+specification+has+a+new+version+in:title+state:open+type:issue+repo:" + repo,
})
if (issues.data.total_count > 0) {
console.log("There's already an open issue for that, therefore not creating.")
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "TUF specification has a new version - " + latest_version,
body: "Hey, it seems there's a newer version of the TUF specification - [" + latest_version +
"](https://github.com/theupdateframework/specification/blob/" + latest_version + "/tuf-spec.md)" +
"\n\n" +
"The version which [" + repo + "](https://github.com/" + repo + ") states it supports is - [" + supported_version +
"](https://github.com/theupdateframework/specification/blob/" + supported_version + "/tuf-spec.md)" +
"\n\n" +
"The following is a comparison of what changed between the two versions - [Compare " + supported_version + " to " + latest_version +"](https://github.com/theupdateframework/specification/compare/" + supported_version + "..." + latest_version + ")" +
"\n\n" +
"Please review the newer version and address the changes."
})
console.log("New issue created.")
}
} else {
console.log(
"The latest TUF specification version (" + latest_version + ") matches with the version that " + repo + " supports (" +
supported_version + ")"
)
}