initial commit
This commit is contained in:
commit
ddd1615db0
2 files changed
+128
No files matched your search
@@ -0,0 +1,125 @@
|
||||
name: Build and Publish RPM
|
||||
|
||||
on:
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
schedule:
|
||||
- cron: "@daily"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: "ubuntu-latest-intranet"
|
||||
container:
|
||||
image: gitea.psi.ch/images/rhel9-developer-gitea-actions
|
||||
env:
|
||||
owner: "envmodules"
|
||||
repository: "modules"
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Check for latest release on GitHub
|
||||
id: check_release
|
||||
run: |
|
||||
echo "::notice::Checking ${{ env.owner }}/${{ env.repository }} for new releases"
|
||||
|
||||
# Fetch all releases and sort them by creation date descending, we only need the latest release tag/date info
|
||||
API_OUTPUT=$(curl -s \
|
||||
"https://api.github.com/repos/${{ env.owner }}/${{ env.repository }}/releases/latest")
|
||||
|
||||
# Check if API call failed or returned no data
|
||||
if [ "$API_OUTPUT" == '[]' ]; then
|
||||
echo "::error::No releases found in the target repository."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "::group::API Output"
|
||||
echo "${API_OUTPUT}"
|
||||
echo "::endgroup::"
|
||||
|
||||
# Extract the tag name and published date of the latest release
|
||||
LATEST_TAG=$(echo "${API_OUTPUT}" | jq -r '.tag_name')
|
||||
PUBLISH_DATE=$(echo "${API_OUTPUT}" | jq -r '.published_at')
|
||||
|
||||
echo "::notice:: Found latest version: ${LATEST_TAG} published on ${PUBLISH_DATE}"
|
||||
|
||||
# Set output variables for subsequent steps
|
||||
echo "latest_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
|
||||
echo "publish_date=${PUBLISH_DATE}" >> $GITHUB_OUTPUT
|
||||
# echo "file=codium-${LATEST_TAG}-el8.x86_64.rpm" >> $GITHUB_OUTPUT
|
||||
|
||||
# Check if the release already exists on Gitea
|
||||
- name: Check if release exists on Gitea
|
||||
id: check_release_exists
|
||||
run: |
|
||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/tags/${{ steps.check_release.outputs.latest_tag }}")
|
||||
|
||||
if [ "$HTTP_STATUS" -eq 200 ]; then
|
||||
echo "::notice::Release already exists. Skipping step."
|
||||
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "::notice::Release does not exist."
|
||||
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# - name: Download latest release from GitHub
|
||||
# if: steps.check_release_exists.outputs.exists != 'true'
|
||||
# run: |
|
||||
# DOWNLOAD_URL="https://github.com/${{ env.owner }}/${{ env.repository }}/releases/download/${{ steps.check_release.outputs.latest_tag }}/${{ steps.check_release.outputs.file }}"
|
||||
|
||||
# echo "::notice::Downloading release from $DOWNLOAD_URL ..."
|
||||
# curl -L -o "${{ steps.check_release.outputs.file }}" "$DOWNLOAD_URL"
|
||||
|
||||
# # - name: Build RPM
|
||||
# # if: steps.check_release_exists.outputs.exists != 'true'
|
||||
# # run: |
|
||||
# # VERSION="${{ steps.check_release.outputs.latest_tag }}"
|
||||
# # VERSION="${VERSION#v}" # remove leading 'v' if present
|
||||
# # sed -i "s/^Version:.*/Version: ${VERSION}/" uv.spec
|
||||
|
||||
# # # move the tar file to the right place
|
||||
# # mkdir -p /data/SOURCES/
|
||||
# # mv "${{ env.file }}" /data/SOURCES/
|
||||
|
||||
# # rpmbuild -ba uv.spec
|
||||
# # find /data/RPMS
|
||||
|
||||
# - name: Upload RHEL8 RPM to Gitea
|
||||
# if: steps.check_release_exists.outputs.exists != 'true'
|
||||
# uses: actions/upload-rpm@v1
|
||||
# with:
|
||||
# owner: lx_packages_rhel8
|
||||
# token: "${{ secrets.PACKAGES_DEPLOY_TOKEN }}"
|
||||
# files: "${{ steps.check_release.outputs.file }}"
|
||||
|
||||
# - name: Upload RHEL9 RPM to Gitea
|
||||
# if: steps.check_release_exists.outputs.exists != 'true'
|
||||
# uses: actions/upload-rpm@v1
|
||||
# with:
|
||||
# owner: lx_packages_rhel9
|
||||
# token: "${{ secrets.PACKAGES_DEPLOY_TOKEN }}"
|
||||
# files: "${{ steps.check_release.outputs.file }}"
|
||||
|
||||
# - name: Upload RHEL10 RPM to Gitea
|
||||
# if: steps.check_release_exists.outputs.exists != 'true'
|
||||
# uses: actions/upload-rpm@v1
|
||||
# with:
|
||||
# owner: lx_packages_rhel10
|
||||
# token: "${{ secrets.PACKAGES_DEPLOY_TOKEN }}"
|
||||
# files: "${{ steps.check_release.outputs.file }}"
|
||||
|
||||
# - name: Create and upload release on Gitea
|
||||
# if: steps.check_release_exists.outputs.exists != 'true'
|
||||
# uses: actions/gitea-release-action@v1
|
||||
# env:
|
||||
# NODE_OPTIONS: "--experimental-fetch"
|
||||
# with:
|
||||
# name: ${{ steps.check_release.outputs.latest_tag }}
|
||||
# tag_name: ${{ steps.check_release.outputs.latest_tag }}
|
||||
# release_name: ${{ steps.check_release.outputs.latest_tag }}
|
||||
# body: "Release ${{ steps.check_release.outputs.latest_tag }} published on ${{ steps.check_release.outputs.publish_date }}"
|
||||
# # files: ./${{ steps.check_release.outputs.file }}
|
||||
Reference in new issue
Block a user