gitea: better organization
All checks were successful
GTK RPM Release / build-gtk-rpm-release (push) Successful in 3m22s
All checks were successful
GTK RPM Release / build-gtk-rpm-release (push) Successful in 3m22s
This commit is contained in:
61
.gitea/scripts/prepare-rpm-release-assets.sh
Executable file
61
.gitea/scripts/prepare-rpm-release-assets.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
: "${RELEASE_TAG:?Missing RELEASE_TAG}"
|
||||
: "${TAG_PREFIX:?Missing TAG_PREFIX}"
|
||||
: "${ASSETS_DIR:?Missing ASSETS_DIR}"
|
||||
: "${RPM_BINARY_DIR:?Missing RPM_BINARY_DIR}"
|
||||
: "${RPM_BINARY_PATTERN_PREFIX:?Missing RPM_BINARY_PATTERN_PREFIX}"
|
||||
: "${RPM_DISTRO_NAME:?Missing RPM_DISTRO_NAME}"
|
||||
: "${RPM_DISTRO_VERSION:?Missing RPM_DISTRO_VERSION}"
|
||||
: "${GITHUB_ENV:?Missing GITHUB_ENV}"
|
||||
|
||||
version="${RELEASE_TAG#${TAG_PREFIX}}"
|
||||
if [[ -z "$version" || "$version" == "$RELEASE_TAG" ]]; then
|
||||
echo "Expected tag in the form ${TAG_PREFIX}{version}, got: $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "${EXPECTED_VERSION:-}" && "$EXPECTED_VERSION" != "$version" ]]; then
|
||||
echo "Release tag version ($version) does not match expected package version ($EXPECTED_VERSION)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "$ASSETS_DIR"
|
||||
mkdir -p "$ASSETS_DIR"
|
||||
|
||||
found=0
|
||||
binary_pattern="${RPM_BINARY_PATTERN_PREFIX}${version}-*.rpm"
|
||||
if [[ -d "$RPM_BINARY_DIR" ]]; then
|
||||
find_cmd=(
|
||||
find "$RPM_BINARY_DIR" -type f -name "$binary_pattern"
|
||||
)
|
||||
while IFS= read -r exclude; do
|
||||
[[ -n "$exclude" ]] || continue
|
||||
find_cmd+=( ! -name "$exclude" )
|
||||
done <<< "${RPM_BINARY_EXCLUDE_PATTERNS:-}"
|
||||
find_cmd+=( -exec cp '{}' "$ASSETS_DIR/" ';' )
|
||||
"${find_cmd[@]}"
|
||||
fi
|
||||
|
||||
if find "$ASSETS_DIR" -maxdepth 1 -type f -name '*.rpm' | grep -q .; then
|
||||
found=1
|
||||
fi
|
||||
|
||||
if [[ -n "${RPM_SOURCE_DIR:-}" && -n "${RPM_SOURCE_PATTERN_PREFIX:-}" && -d "$RPM_SOURCE_DIR" ]]; then
|
||||
source_pattern="${RPM_SOURCE_PATTERN_PREFIX}${version}-*.src.rpm"
|
||||
find "$RPM_SOURCE_DIR" -type f -name "$source_pattern" -exec cp '{}' "$ASSETS_DIR/" ';'
|
||||
fi
|
||||
|
||||
if [[ "$found" -ne 1 ]]; then
|
||||
echo "No RPM artifacts were produced." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package_group="${RPM_PACKAGE_GROUP:-${RPM_DISTRO_NAME}/${RPM_DISTRO_VERSION}}"
|
||||
|
||||
{
|
||||
printf 'RELEASE_VERSION=%s\n' "$version"
|
||||
printf 'RELEASE_ASSETS_DIR=%s\n' "$ASSETS_DIR"
|
||||
printf 'RPM_PACKAGE_GROUP=%s\n' "$package_group"
|
||||
} >> "$GITHUB_ENV"
|
||||
65
.gitea/scripts/upload-rpm-packages.sh
Executable file
65
.gitea/scripts/upload-rpm-packages.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
: "${GITEA_SERVER_URL:?Missing GITEA_SERVER_URL}"
|
||||
: "${GITEA_REPOSITORY_OWNER:?Missing GITEA_REPOSITORY_OWNER}"
|
||||
: "${RELEASE_ASSETS_DIR:?Missing RELEASE_ASSETS_DIR}"
|
||||
|
||||
owner="${GITEA_REPOSITORY_OWNER}"
|
||||
package_user="${RPM_PACKAGE_USERNAME:-${GITEA_REPOSITORY_OWNER}}"
|
||||
token="${RPM_PACKAGE_TOKEN:-}"
|
||||
group="${RPM_PACKAGE_GROUP:-}"
|
||||
|
||||
if [[ -z "$package_user" ]]; then
|
||||
echo "Missing package upload username. Set repository or organization variable RPM_PACKAGE_USERNAME." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$token" ]]; then
|
||||
echo "Missing package upload token. Set repository or organization secret RPM_PACKAGE_TOKEN." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
upload_url="${GITEA_SERVER_URL%/}/api/packages/${owner}/rpm"
|
||||
if [[ -n "$group" ]]; then
|
||||
upload_url="${upload_url}/${group}"
|
||||
fi
|
||||
upload_url="${upload_url}/upload"
|
||||
|
||||
shopt -s nullglob
|
||||
found_rpm=0
|
||||
for rpm in "$RELEASE_ASSETS_DIR"/*.rpm; do
|
||||
case "$rpm" in
|
||||
*.src.rpm)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
found_rpm=1
|
||||
http_code="$(curl --silent --show-error \
|
||||
--write-out '%{http_code}' \
|
||||
--output /tmp/package-upload-response \
|
||||
--user "${package_user}:${token}" \
|
||||
--upload-file "$rpm" \
|
||||
"$upload_url")"
|
||||
|
||||
case "$http_code" in
|
||||
201)
|
||||
echo "Uploaded $(basename "$rpm") to the RPM package registry."
|
||||
;;
|
||||
409)
|
||||
echo "Package already exists for $(basename "$rpm"); skipping duplicate upload."
|
||||
;;
|
||||
*)
|
||||
echo "Failed to upload $(basename "$rpm") to $upload_url (HTTP $http_code)." >&2
|
||||
cat /tmp/package-upload-response >&2 || true
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
if [[ "$found_rpm" -ne 1 ]]; then
|
||||
echo "No binary RPM artifacts were found to upload." >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -61,22 +61,10 @@ jobs:
|
||||
working-directory: core
|
||||
run: make rpm
|
||||
|
||||
- name: Prepare release assets
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
RPM_PACKAGE_GROUP: ${{ vars.RPM_PACKAGE_GROUP }}
|
||||
RPM_DISTRO_NAME: ${{ env.RPM_DISTRO_NAME }}
|
||||
RPM_DISTRO_VERSION: ${{ env.RPM_DISTRO_VERSION }}
|
||||
- name: Read Core Package Version
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
version="${RELEASE_TAG#release/core/}"
|
||||
if [ -z "$version" ] || [ "$version" = "$RELEASE_TAG" ]; then
|
||||
echo "Expected tag in the form release/core/{version}, got: $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package_version="$(awk -F ' = ' '
|
||||
version="$(awk -F ' = ' '
|
||||
$0 == "[package]" { in_pkg = 1; next }
|
||||
/^\[/ { in_pkg = 0 }
|
||||
in_pkg && $1 == "version" {
|
||||
@@ -85,40 +73,24 @@ jobs:
|
||||
exit
|
||||
}
|
||||
' core/kordophoned/Cargo.toml)"
|
||||
|
||||
if [ -z "$package_version" ]; then
|
||||
if [ -z "$version" ]; then
|
||||
echo "Could not determine kordophoned package version from core/kordophoned/Cargo.toml." >&2
|
||||
exit 1
|
||||
fi
|
||||
printf 'CORE_PACKAGE_VERSION=%s\n' "$version" >> "$GITHUB_ENV"
|
||||
|
||||
if [ "$package_version" != "$version" ]; then
|
||||
echo "Release tag version ($version) does not match kordophoned package version ($package_version)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
assets_dir="${{ gitea.workspace }}/release-assets/core"
|
||||
rpm_dir="${{ gitea.workspace }}/core/target/generate-rpm"
|
||||
|
||||
rm -rf "$assets_dir"
|
||||
mkdir -p "$assets_dir"
|
||||
|
||||
if [ -d "$rpm_dir" ]; then
|
||||
find "$rpm_dir" -maxdepth 1 -type f -name "kordophoned-${version}-*.rpm" \
|
||||
-exec cp '{}' "$assets_dir/" ';'
|
||||
fi
|
||||
|
||||
if ! find "$assets_dir" -maxdepth 1 -type f -name '*.rpm' | grep -q .; then
|
||||
echo "No core RPM artifacts were produced." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package_group="${RPM_PACKAGE_GROUP:-${RPM_DISTRO_NAME}/${RPM_DISTRO_VERSION}}"
|
||||
|
||||
{
|
||||
printf 'RELEASE_VERSION=%s\n' "$version"
|
||||
printf 'RELEASE_ASSETS_DIR=%s\n' "$assets_dir"
|
||||
printf 'RPM_PACKAGE_GROUP=%s\n' "$package_group"
|
||||
} >> "$GITHUB_ENV"
|
||||
- name: Prepare release assets
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
TAG_PREFIX: release/core/
|
||||
ASSETS_DIR: ${{ gitea.workspace }}/release-assets/core
|
||||
RPM_BINARY_DIR: ${{ gitea.workspace }}/core/target/generate-rpm
|
||||
RPM_BINARY_PATTERN_PREFIX: kordophoned-
|
||||
RPM_PACKAGE_GROUP: ${{ vars.RPM_PACKAGE_GROUP }}
|
||||
RPM_DISTRO_NAME: ${{ env.RPM_DISTRO_NAME }}
|
||||
RPM_DISTRO_VERSION: ${{ env.RPM_DISTRO_VERSION }}
|
||||
EXPECTED_VERSION: ${{ env.CORE_PACKAGE_VERSION }}
|
||||
run: ./.gitea/scripts/prepare-rpm-release-assets.sh
|
||||
|
||||
- name: Upload RPMs to Gitea package registry
|
||||
env:
|
||||
@@ -128,68 +100,7 @@ jobs:
|
||||
RPM_PACKAGE_TOKEN: ${{ secrets.RPM_PACKAGE_TOKEN }}
|
||||
RPM_PACKAGE_USERNAME: ${{ vars.RPM_PACKAGE_USERNAME }}
|
||||
RELEASE_ASSETS_DIR: ${{ env.RELEASE_ASSETS_DIR }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
owner="${GITEA_REPOSITORY_OWNER}"
|
||||
package_user="${RPM_PACKAGE_USERNAME:-${GITEA_REPOSITORY_OWNER}}"
|
||||
token="${RPM_PACKAGE_TOKEN:-}"
|
||||
group="${RPM_PACKAGE_GROUP:-}"
|
||||
|
||||
if [ -z "$owner" ]; then
|
||||
echo "Could not determine package owner from workflow context." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$package_user" ]; then
|
||||
echo "Missing package upload username. Set repository or organization variable RPM_PACKAGE_USERNAME." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$token" ]; then
|
||||
echo "Missing package upload token. Set repository or organization secret RPM_PACKAGE_TOKEN." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
upload_url="${GITEA_SERVER_URL%/}/api/packages/${owner}/rpm"
|
||||
if [ -n "$group" ]; then
|
||||
upload_url="${upload_url}/${group}"
|
||||
fi
|
||||
upload_url="${upload_url}/upload"
|
||||
|
||||
found_rpm=0
|
||||
for rpm in "$RELEASE_ASSETS_DIR"/*.rpm; do
|
||||
if [ ! -e "$rpm" ] || [ "${rpm##*.}" != "rpm" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
found_rpm=1
|
||||
http_code="$(curl --silent --show-error \
|
||||
--write-out '%{http_code}' \
|
||||
--output /tmp/package-upload-response \
|
||||
--user "${package_user}:${token}" \
|
||||
--upload-file "$rpm" \
|
||||
"$upload_url")"
|
||||
|
||||
case "$http_code" in
|
||||
201)
|
||||
echo "Uploaded $(basename "$rpm") to the RPM package registry."
|
||||
;;
|
||||
409)
|
||||
echo "Package already exists for $(basename "$rpm"); skipping duplicate upload."
|
||||
;;
|
||||
*)
|
||||
echo "Failed to upload $(basename "$rpm") to $upload_url (HTTP $http_code)." >&2
|
||||
cat /tmp/package-upload-response >&2 || true
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$found_rpm" -ne 1 ]; then
|
||||
echo "No core RPM artifacts were found to upload." >&2
|
||||
exit 1
|
||||
fi
|
||||
run: ./.gitea/scripts/upload-rpm-packages.sh
|
||||
|
||||
- name: Create Gitea release
|
||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||
|
||||
@@ -63,48 +63,19 @@ jobs:
|
||||
- name: Prepare release assets
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.ref_name }}
|
||||
TAG_PREFIX: release/gtk/
|
||||
ASSETS_DIR: ${{ gitea.workspace }}/release-assets/gtk
|
||||
RPM_BINARY_DIR: /root/rpmbuild/RPMS
|
||||
RPM_BINARY_PATTERN_PREFIX: kordophone-
|
||||
RPM_BINARY_EXCLUDE_PATTERNS: |
|
||||
*-debuginfo-*
|
||||
*-debugsource-*
|
||||
RPM_PACKAGE_GROUP: ${{ vars.RPM_PACKAGE_GROUP }}
|
||||
RPM_SOURCE_DIR: /root/rpmbuild/SRPMS
|
||||
RPM_SOURCE_PATTERN_PREFIX: kordophone-
|
||||
RPM_DISTRO_NAME: ${{ env.RPM_DISTRO_NAME }}
|
||||
RPM_DISTRO_VERSION: ${{ env.RPM_DISTRO_VERSION }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
version="${RELEASE_TAG#release/gtk/}"
|
||||
if [ -z "$version" ] || [ "$version" = "$RELEASE_TAG" ]; then
|
||||
echo "Expected tag in the form release/gtk/{version}, got: $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
assets_dir="${{ gitea.workspace }}/release-assets/gtk"
|
||||
rpmbuild_dir="${HOME}/rpmbuild"
|
||||
|
||||
rm -rf "$assets_dir"
|
||||
mkdir -p "$assets_dir"
|
||||
|
||||
if [ -d "$rpmbuild_dir/RPMS" ]; then
|
||||
find "$rpmbuild_dir/RPMS" -type f -name "kordophone-${version}-*.rpm" \
|
||||
! -name '*-debuginfo-*' \
|
||||
! -name '*-debugsource-*' \
|
||||
-exec cp '{}' "$assets_dir/" ';'
|
||||
fi
|
||||
|
||||
if [ -d "$rpmbuild_dir/SRPMS" ]; then
|
||||
find "$rpmbuild_dir/SRPMS" -type f -name "kordophone-${version}-*.src.rpm" \
|
||||
-exec cp '{}' "$assets_dir/" ';'
|
||||
fi
|
||||
|
||||
if ! find "$assets_dir" -maxdepth 1 -type f -name '*.rpm' | grep -q .; then
|
||||
echo "No RPM artifacts were produced." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package_group="${RPM_PACKAGE_GROUP:-${RPM_DISTRO_NAME}/${RPM_DISTRO_VERSION}}"
|
||||
|
||||
{
|
||||
printf 'RELEASE_VERSION=%s\n' "$version"
|
||||
printf 'RELEASE_ASSETS_DIR=%s\n' "$assets_dir"
|
||||
printf 'RPM_PACKAGE_GROUP=%s\n' "$package_group"
|
||||
} >> "$GITHUB_ENV"
|
||||
run: ./.gitea/scripts/prepare-rpm-release-assets.sh
|
||||
|
||||
- name: Upload RPMs to Gitea package registry
|
||||
env:
|
||||
@@ -114,73 +85,7 @@ jobs:
|
||||
RPM_PACKAGE_TOKEN: ${{ secrets.RPM_PACKAGE_TOKEN }}
|
||||
RPM_PACKAGE_USERNAME: ${{ vars.RPM_PACKAGE_USERNAME }}
|
||||
RELEASE_ASSETS_DIR: ${{ env.RELEASE_ASSETS_DIR }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
owner="${GITEA_REPOSITORY_OWNER}"
|
||||
package_user="${RPM_PACKAGE_USERNAME:-${GITEA_REPOSITORY_OWNER}}"
|
||||
token="${RPM_PACKAGE_TOKEN:-}"
|
||||
group="${RPM_PACKAGE_GROUP:-}"
|
||||
|
||||
if [ -z "$owner" ]; then
|
||||
echo "Could not determine package owner from workflow context." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$package_user" ]; then
|
||||
echo "Missing package upload username. Set repository or organization variable RPM_PACKAGE_USERNAME." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$token" ]; then
|
||||
echo "Missing package upload token. Set repository or organization secret RPM_PACKAGE_TOKEN." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
upload_url="${GITEA_SERVER_URL%/}/api/packages/${owner}/rpm"
|
||||
if [ -n "$group" ]; then
|
||||
upload_url="${upload_url}/${group}"
|
||||
fi
|
||||
upload_url="${upload_url}/upload"
|
||||
|
||||
found_rpm=0
|
||||
for rpm in "$RELEASE_ASSETS_DIR"/*.rpm; do
|
||||
if [ ! -e "$rpm" ] || [ "${rpm##*.}" != "rpm" ]; then
|
||||
continue
|
||||
fi
|
||||
case "$rpm" in
|
||||
*.src.rpm)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
found_rpm=1
|
||||
http_code="$(curl --silent --show-error \
|
||||
--write-out '%{http_code}' \
|
||||
--output /tmp/package-upload-response \
|
||||
--user "${package_user}:${token}" \
|
||||
--upload-file "$rpm" \
|
||||
"$upload_url")"
|
||||
|
||||
case "$http_code" in
|
||||
201)
|
||||
echo "Uploaded $(basename "$rpm") to the RPM package registry."
|
||||
;;
|
||||
409)
|
||||
echo "Package already exists for $(basename "$rpm"); skipping duplicate upload."
|
||||
;;
|
||||
*)
|
||||
echo "Failed to upload $(basename "$rpm") to $upload_url (HTTP $http_code)." >&2
|
||||
cat /tmp/package-upload-response >&2 || true
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$found_rpm" -ne 1 ]; then
|
||||
echo "No binary RPM artifacts were found to upload." >&2
|
||||
exit 1
|
||||
fi
|
||||
run: ./.gitea/scripts/upload-rpm-packages.sh
|
||||
|
||||
- name: Create Gitea release
|
||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.codex
|
||||
ext/
|
||||
target/
|
||||
|
||||
Reference in New Issue
Block a user