-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Deploy RPM to OBS * Add empty build section * Run spec-cleaner * Number source
- Loading branch information
Showing
5 changed files
with
227 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ on: | |
push: | ||
branches: [main] | ||
pull_request: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
tlint: | ||
|
@@ -20,3 +22,62 @@ jobs: | |
fetch-depth: 0 | ||
- name: Run TLint | ||
run: "/home/tlint/tlint lint -f /data/checks" | ||
|
||
obs-commit-rpm: | ||
name: Commit to OBS to generate a RPM package | ||
needs: [tlint] | ||
runs-on: ubuntu-20.04 | ||
if: github.ref == 'refs/heads/main' || github.event_name == 'release' | ||
container: | ||
image: ghcr.io/trento-project/continuous-delivery:main | ||
env: | ||
OBS_USER: ${{ secrets.OBS_USER }} | ||
OBS_PASS: ${{ secrets.OBS_PASS }} | ||
OBS_PROJECT: ${{ secrets.OBS_PROJECT }} | ||
OSC_CHECKOUT_DIR: /tmp/trento-checks-package | ||
REPOSITORY: ${{ github.repository }} | ||
FOLDER: packaging/suse/rpm | ||
options: -u 0:0 | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Configure OSC | ||
run: | | ||
mkdir -p $HOME/.config/osc | ||
cp /home/osc/.config/osc/oscrc $HOME/.config/osc | ||
/scripts/init_osc_creds.sh | ||
- name: Prepare _service file | ||
run: | | ||
git config --global --add safe.directory /__w/checks/checks | ||
VERSION=$(./hack/get_version_from_git.sh) | ||
sed -i 's~%%REVISION%%~${{ github.sha }}~' $FOLDER/_service && \ | ||
sed -i 's~%%REPOSITORY%%~'"${REPOSITORY}"'~' $FOLDER/_service && \ | ||
sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/_service | ||
- name: Checkout and prepare OBS package | ||
run: | | ||
osc checkout $OBS_PROJECT trento-checks -o $OSC_CHECKOUT_DIR | ||
cp $FOLDER/_service $OSC_CHECKOUT_DIR | ||
cp $FOLDER/trento-checks.spec $OSC_CHECKOUT_DIR | ||
rm -vf $OSC_CHECKOUT_DIR/*.tar.gz | ||
pushd $OSC_CHECKOUT_DIR | ||
osc service manualrun | ||
rm -vf $OSC_CHECKOUT_DIR/*.tgz | ||
- name: Prepare trento-checks.changes file | ||
# The .changes file is updated only in release creation. This current task should be improved | ||
# in order to add the current rolling release notes | ||
if: github.event_name == 'release' | ||
run: | | ||
git config --global --add safe.directory /__w/checks/checks | ||
VERSION=$(./hack/get_version_from_git.sh) | ||
TAG=$(echo $VERSION | cut -f1 -d+) | ||
hack/gh_release_to_obs_changeset.py $REPOSITORY -a [email protected] -t $TAG -f $OSC_CHECKOUT_DIR/trento-checks.changes | ||
- name: Commit changes into OBS | ||
run: | | ||
pushd $OSC_CHECKOUT_DIR | ||
osc ar | ||
osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
set -e | ||
set -o pipefail | ||
|
||
TAG=$( git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1 ) | ||
|
||
if [ -n "${TAG}" ]; then | ||
COMMITS_SINCE_TAG=$(git rev-list "${TAG}".. --count) | ||
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then | ||
COMMIT_SHA=$(git show -s --format=%ct.%h HEAD) | ||
SUFFIX="+git.dev${COMMITS_SINCE_TAG}.${COMMIT_SHA}" | ||
fi | ||
else | ||
TAG="0" | ||
fi | ||
|
||
echo "${TAG}${SUFFIX}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import json | ||
import os | ||
import sys | ||
import textwrap | ||
import urllib.request | ||
import urllib.error | ||
from datetime import datetime | ||
from datetime import timezone | ||
import tempfile | ||
|
||
parser = argparse.ArgumentParser(description="Add a GitHub release to an RPM changelog", usage=argparse.SUPPRESS) | ||
parser.add_argument("repo", help="GitHub repository (owner/name)") | ||
parser.add_argument("-t", "--tag", help="A specific Git tag to get; if none, latest will be used") | ||
parser.add_argument("-a", "--author", help="The author of the RPM changelog entry") | ||
parser.add_argument("-f", "--file", help="Prepend the new changelog entry to file instead of printing in stdout") | ||
|
||
if len(sys.argv) == 1: | ||
parser.print_help(sys.stderr) | ||
sys.exit(1) | ||
|
||
args = parser.parse_args() | ||
|
||
releaseSegment = f"/tags/{args.tag}" if args.tag else "/latest" | ||
url = f'https://api.github.com/repos/{args.repo}/releases{releaseSegment}' | ||
|
||
request = urllib.request.Request(url) | ||
|
||
githubToken = os.getenv("GITHUB_OAUTH_TOKEN") | ||
if githubToken: | ||
request.add_header("Authorization", "token " + githubToken) | ||
|
||
try: | ||
response = urllib.request.urlopen(request) | ||
except urllib.error.HTTPError as error: | ||
if error.code == 404: | ||
print(f"Release {args.tag} not found in {args.repo}. Skipping changelog generation.") | ||
sys.exit(0) | ||
print(f"GitHub API responded with a {error.code} error!", file=sys.stderr) | ||
print("Url:", url, file=sys.stderr) | ||
print("Response:", json.dumps(json.load(error), indent=4), file=sys.stderr, sep="\n") | ||
sys.exit(1) | ||
|
||
release = json.load(response) | ||
|
||
releaseDate = datetime.strptime(release['published_at'], "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc) | ||
|
||
with tempfile.TemporaryFile("r+") as temp: | ||
print("-------------------------------------------------------------------", file=temp) | ||
|
||
print(f"{releaseDate.strftime('%a %b %d %H:%M:%S %Z %Y')}", end="", file=temp) | ||
if args.author: | ||
print(f" - {args.author}", end="", file=temp) | ||
print("\n", file=temp) | ||
|
||
print(f"- Release {args.tag}", end="", file=temp) | ||
if release['name'] and release['name'] != args.tag: | ||
print(f" - {release['name']}", end="", file=temp) | ||
print("\n", file=temp) | ||
|
||
if release['body']: | ||
print(textwrap.indent(release['body'], " "), file=temp, end="\n\n") | ||
temp.seek(0) | ||
|
||
if args.file: | ||
try: | ||
with open(args.file, "r") as prev: | ||
old = prev.read() | ||
except FileNotFoundError: | ||
old = "" | ||
with open(args.file, "w") as new: | ||
for line in temp: | ||
new.write(line) | ||
new.write(old) | ||
sys.exit(0) | ||
|
||
print(temp.read()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<services> | ||
<service name="tar_scm" mode="manual"> | ||
<param name="url">https://github.com/%%REPOSITORY%%.git</param> | ||
<param name="scm">git</param> | ||
<param name="revision">%%REVISION%%</param> | ||
<param name="exclude">.git</param> | ||
<param name="exclude">.github</param> | ||
<param name="versionformat">%%VERSION%%</param> | ||
<param name="filename">trento-checks</param> | ||
</service> | ||
<service name="set_version" mode="manual"> | ||
<param name="file">trento-checks.spec</param> | ||
</service> | ||
<service name="recompress" mode="manual"> | ||
<param name="file">*.tar</param> | ||
<param name="compression">gz</param> | ||
</service> | ||
</services> |
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