generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7646a23
commit 9d0dfae
Showing
7 changed files
with
426 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
name: CI Copr | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
release: | ||
types: | ||
- prereleased | ||
- released | ||
|
||
concurrency: | ||
group: "${{ github.workflow }}-${{ github.ref }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
call-copr-ci: | ||
uses: ./.github/workflows/copr-ci.yml | ||
with: | ||
copr_pr_webhook_token: "05fc9b07-a19b-4f83-89b2-ae1e7e0b5282" | ||
github_org_owner: LizardByte | ||
copr_ownername: lizardbyte | ||
auto_update_package: true | ||
job_timeout: 60 | ||
secrets: | ||
COPR_BETA_WEBHOOK_TOKEN: ${{ secrets.COPR_BETA_WEBHOOK_TOKEN }} | ||
COPR_STABLE_WEBHOOK_TOKEN: ${{ secrets.COPR_STABLE_WEBHOOK_TOKEN }} | ||
COPR_CLI_CONFIG: ${{ secrets.COPR_CLI_CONFIG }} | ||
|
||
release: | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
needs: | ||
- call-copr-ci | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Release | ||
id: setup-release | ||
uses: LizardByte/setup-release-action@v2024.919.143601 | ||
with: | ||
github_token: ${{ secrets.GH_BOT_TOKEN }} | ||
|
||
- name: Create Release | ||
id: action | ||
uses: LizardByte/create-release-action@v2024.919.143026 | ||
with: | ||
allowUpdates: false | ||
artifacts: '' | ||
body: ${{ steps.setup-release.outputs.release_body }} | ||
generateReleaseNotes: ${{ steps.setup-release.outputs.release_generate_release_notes }} | ||
name: ${{ steps.setup-release.outputs.release_tag }} | ||
prerelease: true | ||
tag: ${{ steps.setup-release.outputs.release_tag }} | ||
token: ${{ secrets.GH_BOT_TOKEN }} |
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,171 @@ | ||
--- | ||
name: CI Copr Call | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
copr_pr_webhook_token: | ||
description: 'Copr PR webhook key. This should not be secret if you want it to work for PRs from forks.' | ||
required: true | ||
type: string | ||
github_org_owner: | ||
description: 'GitHub organization owner. This will prevent user forks from triggering the workflow.' | ||
required: true | ||
type: string | ||
copr_ownername: | ||
description: 'User or group name.' | ||
required: true | ||
type: string | ||
auto_update_package: | ||
description: 'Automatically create/update a package in Copr.' | ||
required: false | ||
type: boolean | ||
default: true | ||
job_timeout: | ||
description: 'Job timeout in minutes.' | ||
required: false | ||
type: number | ||
default: 60 | ||
secrets: | ||
COPR_BETA_WEBHOOK_TOKEN: | ||
description: 'Copr beta webhook token. This should be a secret.' | ||
required: true | ||
COPR_STABLE_WEBHOOK_TOKEN: | ||
description: 'Copr stable webhook token. This should be a secret.' | ||
required: true | ||
COPR_CLI_CONFIG: | ||
description: 'Copr CLI configuration file. See https://copr.fedorainfracloud.org/api' | ||
required: true | ||
|
||
jobs: | ||
package-init: | ||
name: Create/update copr package | ||
runs-on: ubuntu-latest | ||
container: fedora:latest | ||
env: | ||
BASE_URL: https://copr.fedorainfracloud.org/api_3 | ||
OWNERNAME: ${{ inputs.copr_ownername }} | ||
PACKAGE_NAME: ${{ github.event.repository.name }} | ||
SOURCE_TYPE_TEXT: "custom" | ||
steps: | ||
- name: Debug inputs | ||
run: | | ||
echo "inputs:" | ||
echo "copr_pr_webhook_token: ${{ inputs.copr_pr_webhook_token }}" | ||
echo "github_org_owner: ${{ inputs.github_org_owner }}" | ||
echo "copr_ownername: ${{ inputs.copr_ownername }}" | ||
echo "auto_update_package: ${{ inputs.auto_update_package }}" | ||
echo "job_timeout: ${{ inputs.job_timeout }}" | ||
- name: Test secrets | ||
id: test_secrets | ||
if: > | ||
github.repository_owner == inputs.github_org_owner && | ||
inputs.auto_update_package == true | ||
run: | | ||
# return if secrets.COPR_CLI_CONFIG is empty | ||
if [ -z "${{ secrets.COPR_CLI_CONFIG }}" ]; then | ||
echo "Copr CLI configuration file is empty. Exiting..." | ||
# if a pull request exit with 0 | ||
if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
echo "SKIP_REMAINING_JOBS=true" >> $GITHUB_OUTPUT | ||
else | ||
exit 1 | ||
fi | ||
else | ||
mkdir -p ~/.config | ||
echo "${{ secrets.COPR_CLI_CONFIG }}" > ~/.config/copr | ||
fi | ||
- name: Install dependencies | ||
if: steps.test_secrets.outputs.SKIP_REMAINING_JOBS != 'true' | ||
run: | | ||
dnf install -y \ | ||
copr-cli \ | ||
jq | ||
- name: create packages | ||
if: steps.test_secrets.outputs.SKIP_REMAINING_JOBS != 'true' | ||
run: | | ||
projects=( | ||
"pulls" | ||
"beta" | ||
"stable" | ||
) | ||
# download the latest copr-ci.sh script | ||
curl https://raw.githubusercontent.com/lizardbyte/copr-ci/master/copr-ci.sh > copr-ci.sh | ||
# set parameters for package creation | ||
script="copr-ci.sh" | ||
builddeps="git jq python3" | ||
resultdir="" | ||
chroot="fedora-latest-x86_64" | ||
for project in "${projects[@]}"; do | ||
# check if 404 on get package (package does not exist) | ||
url="${BASE_URL}/package?ownername=${OWNERNAME}&projectname=${project}&packagename=${PACKAGE_NAME}" | ||
status_code=$(curl --write-out %{http_code} --silent --output /dev/null $url) | ||
if [[ "$status_code" == 404 ]]; then | ||
echo "Creating package for ${project}..." | ||
command="add-package-custom" | ||
else | ||
echo "Editing package for ${project}..." | ||
command="edit-package-custom" | ||
fi | ||
copr-cli \ | ||
${command} \ | ||
--script "${script}" \ | ||
--script-builddeps "${builddeps}" \ | ||
--script-resultdir "${resultdir}" \ | ||
--script-chroot "${chroot}" \ | ||
--name "${PACKAGE_NAME}" \ | ||
--timeout $((60 * ${{ inputs.job_timeout }})) \ | ||
${project} | ||
done | ||
build: | ||
name: Copr build | ||
needs: package-init | ||
if: github.repository_owner == inputs.github_org_owner | ||
runs-on: ubuntu-latest | ||
timeout-minutes: ${{ inputs.job_timeout }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get properties | ||
env: | ||
COPR_PR_WH_TOKEN: ${{ inputs.copr_pr_webhook_token }} | ||
run: | | ||
# package name = repository name | ||
package=${{ github.event.repository.name }} | ||
copr_base="https://copr.fedorainfracloud.org/webhooks/custom-dir/${{ inputs.copr_ownername }}" | ||
# release and released type | ||
if [ "${{ github.event_name }}" = "release" ]; then | ||
if [ "${{ github.event.action }}" = "prereleased" ]; then | ||
COPR_PUSH_WEBHOOK="${copr_base}/beta/${{ secrets.COPR_BETA_WEBHOOK_TOKEN }}/${package}/" | ||
elif [ "${{ github.event.action }}" = "released" ]; then | ||
COPR_PUSH_WEBHOOK="${copr_base}/stable/${{ secrets.COPR_STABLE_WEBHOOK_TOKEN }}/${package}/" | ||
fi | ||
elif [ "${{ github.event_name }}" = "pull_request" ]; then | ||
COPR_PR_WEBHOOK="${copr_base}/pulls:pr:${{ github.event.number }}/${{ env.COPR_PR_WH_TOKEN }}/${package}/" | ||
fi | ||
echo "COPR_PUSH_WEBHOOK=${COPR_PUSH_WEBHOOK}" >> $GITHUB_ENV | ||
echo "COPR_PR_WEBHOOK=${COPR_PR_WEBHOOK}" >> $GITHUB_ENV | ||
echo "COPR_PUSH_WEBHOOK=${COPR_PUSH_WEBHOOK}" | ||
echo "COPR_PR_WEBHOOK=${COPR_PR_WEBHOOK}" | ||
- name: Build | ||
run: | | ||
curl https://raw.githubusercontent.com/praiskup/copr-ci-tooling/main/copr-gh-actions-submit > submit | ||
# if a PR number is added the script will use the PR webhook, otherwise it will use the push webhook | ||
bash submit ${{ github.event.pull_request.number }} |
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,2 @@ | ||
# Ignore JetBrains IDE files | ||
.idea/ |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 LizardByte | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1,2 +1,69 @@ | ||
# template-base | ||
Base repository template for LizardByte. | ||
# copr-ci | ||
Copr automation scripts for CI. This is meant to be used by LizardByte CI/CD pipeline. | ||
|
||
## Usage | ||
|
||
You can replicate this in your own org, by following the examples here. | ||
|
||
1. Create 3 projects/repos in copr | ||
|
||
- `<org>/pulls` (fired on pull_request events) | ||
- `<org>/beta` (fired on prereleased events) | ||
- `<org>/stable` (fired on released events) | ||
|
||
2. Add a workflow to your repo, like so. | ||
|
||
```yml | ||
--- | ||
name: CI Copr | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
release: | ||
types: | ||
- prereleased | ||
- released | ||
|
||
concurrency: | ||
group: "${{ github.workflow }}-${{ github.ref }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
call-copr-ci: | ||
uses: LizardByte/copr-ci/.github/workflows/copr-ci.yml@master | ||
with: | ||
copr_pr_webhook_token: "<fill in your pr token>" | ||
github_org_owner: "<fill in your org>" | ||
copr_ownername: "<fill in your copr owner>" | ||
auto_update_package: true | ||
job_timeout: 60 | ||
secrets: | ||
COPR_BETA_WEBHOOK_TOKEN: ${{ secrets.COPR_BETA_WEBHOOK_TOKEN }} | ||
COPR_STABLE_WEBHOOK_TOKEN: ${{ secrets.COPR_STABLE_WEBHOOK_TOKEN }} | ||
COPR_CLI_CONFIG: ${{ secrets.COPR_CLI_CONFIG }} | ||
``` | ||
3. Add the following secrets to the org: | ||
- `COPR_BETA_WEBHOOK_TOKEN` | ||
- `COPR_STABLE_WEBHOOK_TOKEN` | ||
- `COPR_CLI_CONFIG` - See https://copr.fedorainfracloud.org/api | ||
|
||
NOTE: The webhook secrets should only be the token portion of the webhook URL, not the full URL. | ||
|
||
4. Optionally, add the following to the top of the spec file: | ||
|
||
```rpmspec | ||
# sed will replace these values | ||
%global build_version 0 | ||
%global branch 0 | ||
%global commit 0 | ||
Version: %{build_version} | ||
``` |
Oops, something went wrong.