Skip to content

Commit 4866bd6

Browse files
committed
docs: update readme, license, and add release script
1 parent f4e6fbe commit 4866bd6

3 files changed

Lines changed: 251 additions & 2 deletions

File tree

LICENSE

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5+
6+
Definitions.
7+
8+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
9+
10+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
11+
12+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
13+
14+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
15+
16+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
17+
18+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
19+
20+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
21+
22+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
23+
24+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
25+
26+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
27+
28+
Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
29+
30+
Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
31+
32+
Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
33+
34+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
35+
36+
Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
37+
38+
Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
39+
40+
Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
41+
42+
Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
43+
44+
Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
45+
46+
END OF TERMS AND CONDITIONS
47+
48+
APPENDIX: How to apply the Apache License to your work.
49+
50+
To apply the Apache License to your work, attach the following
51+
boilerplate notice, with the fields enclosed by brackets "[]"
52+
replaced with your own identifying information. (Don't include
53+
the brackets!) The text should be enclosed in the appropriate
54+
comment syntax for the file format. We also recommend that a
55+
file or class name and description of purpose be included on the
56+
same "printed page" as the copyright notice for easier
57+
identification within third-party archives.
58+
59+
Copyright [2026] Renbytes
60+
61+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
62+
63+
http://www.apache.org/licenses/LICENSE-2.0
64+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on: [pull_request]
1010

1111
permissions:
1212
contents: read
13-
security-events: write # Required for SARIF upload
13+
security-events: write # Required for SARIF upload
1414
pull-requests: write # Required for PR review comments
1515

1616
jobs:
@@ -109,4 +109,4 @@ jobs:
109109

110110
## License
111111

112-
MIT
112+
Apache 2.0

scripts/releases/1_github.py

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Tag and push a GitHub release for capsec-github-action.
4+
5+
Usage:
6+
python scripts/releases/1_github.py # dry-run (shows what would happen)
7+
python scripts/releases/1_github.py --push # create tag and push
8+
9+
What it does:
10+
1. Reads the version from action.yml (auto-increments from latest git tag if not set)
11+
2. Checks that the git tag doesn't already exist on GitHub
12+
3. Creates a git tag v{version} and pushes it to origin
13+
4. Updates the floating major tag (v1) to point to the new release
14+
15+
The floating major tag (v1) is how users reference the action:
16+
uses: bordumb/capsec-github-action@v1
17+
18+
Requires:
19+
- python3 (no external dependencies)
20+
- git on PATH
21+
"""
22+
23+
import re
24+
import subprocess
25+
import sys
26+
from pathlib import Path
27+
28+
REPO_ROOT = Path(__file__).resolve().parents[2]
29+
ACTION_YML = REPO_ROOT / "action.yml"
30+
GITHUB_REPO = "bordumb/capsec-github-action"
31+
32+
33+
def get_latest_tag() -> str | None:
34+
"""Get the latest semver tag from git."""
35+
result = subprocess.run(
36+
["git", "tag", "-l", "v*.*.*", "--sort=-v:refname"],
37+
capture_output=True,
38+
text=True,
39+
cwd=REPO_ROOT,
40+
)
41+
tags = result.stdout.strip().splitlines()
42+
return tags[0] if tags else None
43+
44+
45+
def bump_patch(tag: str) -> str:
46+
"""Bump patch version: v1.0.0 -> v1.0.1"""
47+
m = re.match(r"v(\d+)\.(\d+)\.(\d+)", tag)
48+
if not m:
49+
return "v1.0.0"
50+
major, minor, patch = int(m.group(1)), int(m.group(2)), int(m.group(3))
51+
return f"v{major}.{minor}.{patch + 1}"
52+
53+
54+
def get_version() -> str:
55+
"""Determine the next version tag."""
56+
latest = get_latest_tag()
57+
if latest:
58+
return bump_patch(latest)
59+
return "v1.0.0"
60+
61+
62+
def git(*args: str) -> str:
63+
result = subprocess.run(
64+
["git", *args],
65+
capture_output=True,
66+
text=True,
67+
cwd=REPO_ROOT,
68+
)
69+
if result.returncode != 0:
70+
print(f"ERROR: git {' '.join(args)} failed:\n{result.stderr.strip()}", file=sys.stderr)
71+
sys.exit(1)
72+
return result.stdout.strip()
73+
74+
75+
def local_tag_exists(tag: str) -> bool:
76+
result = subprocess.run(
77+
["git", "tag", "-l", tag],
78+
capture_output=True,
79+
text=True,
80+
cwd=REPO_ROOT,
81+
)
82+
return bool(result.stdout.strip())
83+
84+
85+
def remote_tag_exists(tag: str) -> bool:
86+
result = subprocess.run(
87+
["git", "ls-remote", "--tags", "origin", f"refs/tags/{tag}"],
88+
capture_output=True,
89+
text=True,
90+
cwd=REPO_ROOT,
91+
)
92+
return bool(result.stdout.strip())
93+
94+
95+
def delete_local_tag(tag: str) -> None:
96+
subprocess.run(
97+
["git", "tag", "-d", tag],
98+
capture_output=True,
99+
cwd=REPO_ROOT,
100+
)
101+
102+
103+
def main() -> None:
104+
push = "--push" in sys.argv
105+
106+
tag = get_version()
107+
major_tag = re.match(r"(v\d+)", tag).group(1) # e.g., "v1"
108+
latest = get_latest_tag()
109+
110+
print(f"Latest tag: {latest or '(none)'}")
111+
print(f"New tag: {tag}")
112+
print(f"Floating tag: {major_tag} (will point to {tag})")
113+
114+
# Check remote
115+
if remote_tag_exists(tag):
116+
print(f"\nERROR: Git tag {tag} already exists on origin.", file=sys.stderr)
117+
print("Delete the remote tag first or let it auto-bump.", file=sys.stderr)
118+
sys.exit(1)
119+
120+
if local_tag_exists(tag):
121+
print(f"Local tag {tag} exists but not on origin — deleting stale local tag.")
122+
delete_local_tag(tag)
123+
124+
# Clean working tree
125+
status = git("status", "--porcelain")
126+
if status:
127+
print(f"\nERROR: Working tree is not clean:\n{status}", file=sys.stderr)
128+
print("Commit or stash changes before releasing.", file=sys.stderr)
129+
sys.exit(1)
130+
131+
if not push:
132+
print(f"\nDry run: would create and push tag {tag}")
133+
print(f" would update floating tag {major_tag} -> {tag}")
134+
print("Run with --push to execute.")
135+
return
136+
137+
# Create version tag
138+
print(f"\nCreating tag {tag}...", flush=True)
139+
result = subprocess.run(
140+
["git", "tag", "-a", tag, "-m", f"release: {tag}"],
141+
cwd=REPO_ROOT,
142+
)
143+
if result.returncode != 0:
144+
print(f"\nERROR: git tag failed (exit {result.returncode})", file=sys.stderr)
145+
sys.exit(1)
146+
147+
# Push version tag
148+
print(f"Pushing tag {tag} to origin...", flush=True)
149+
result = subprocess.run(
150+
["git", "push", "origin", tag],
151+
cwd=REPO_ROOT,
152+
)
153+
if result.returncode != 0:
154+
print(f"\nERROR: git push failed (exit {result.returncode})", file=sys.stderr)
155+
sys.exit(1)
156+
157+
# Update floating major tag (v1 -> latest)
158+
print(f"Updating floating tag {major_tag} -> {tag}...", flush=True)
159+
if local_tag_exists(major_tag):
160+
delete_local_tag(major_tag)
161+
162+
result = subprocess.run(
163+
["git", "tag", "-fa", major_tag, "-m", f"{major_tag} floating tag -> {tag}"],
164+
cwd=REPO_ROOT,
165+
)
166+
if result.returncode != 0:
167+
print(f"\nERROR: git tag {major_tag} failed (exit {result.returncode})", file=sys.stderr)
168+
sys.exit(1)
169+
170+
result = subprocess.run(
171+
["git", "push", "origin", major_tag, "--force"],
172+
cwd=REPO_ROOT,
173+
)
174+
if result.returncode != 0:
175+
print(f"\nERROR: git push {major_tag} failed (exit {result.returncode})", file=sys.stderr)
176+
sys.exit(1)
177+
178+
print(f"\nDone.")
179+
print(f" Version tag: {tag}")
180+
print(f" Floating: {major_tag} -> {tag}")
181+
print(f" Users reference: uses: {GITHUB_REPO}@{major_tag}")
182+
183+
184+
if __name__ == "__main__":
185+
main()

0 commit comments

Comments
 (0)