Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/trigger_copr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Create a project release automatically on tag creation

name: trigger_copr_on_tag

on:
push:
tags:
- "*" # triggers only if push new tag version, like `0.8.4`

jobs:
build:
name: trigger_copr_on_tag
runs-on: ubuntu-latest
permissions:
repository-projects: write

steps:
- name: Trigger COPR build
run: |
curl --request POST \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"ref_type\": \"tag\",
\"ref\": \"${GITHUB_REF#refs/tags/}\"
}" \
--url "$COPR_URL"
env:
COPR_URL: ${{ secrets.COPR_URL }}
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ Release are available on Github

### Creating a release

#### For Fedora

Fedora releases can automatically be build in a COPR repository by using a [custom
webhook](https://docs.pagure.org/copr.copr/user_documentation.html#custom-webhook) and the `hack/copr.sh` script as
build method.

This expects the webhook to be configured to only react to tag events. If setup this will automatically trigger a
rebuild of the package in the COPR project that receives the custom webhook.

#### Manually

Repository owners can create a new `osdctl` release with the `make release` target. An API token with `repo` permissions is required. [See: https://goreleaser.com/environment/#api-tokens](https://goreleaser.com/environment/#api-tokens)

The goreleaser config (`.goreleaser.yaml`) will look for the token in `~/.config/goreleaser/token`.
Expand Down
117 changes: 117 additions & 0 deletions hack/copr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/usr/bin/env sh

# Check that the event payload exists:
if [[ ! -f hook_payload ]]; then
echo "Event payload file 'hook_payload' doesn't exist"
exit 1
fi

# Check that the event is the creation of a tag:
ref_type=$(cat hook_payload | jq -r .ref_type)
if [[ "${ref_type}" != "tag" ]]; then
echo "Expected reference type 'tag' but got '${ref_type}'"
exit 1
fi

# Check that the tag is well formed:
ref=$(cat hook_payload | jq -r .ref)
if [[ ! "${ref}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Reference '${ref}' isn't well formed"
exit 1
fi

# Set the version to use:
version="${ref:1}"

# Generate the .spec file:
cat > osdctl.spec.in <<"."
# Generated by go2rpm 1.15.0
%bcond check 1
%bcond bootstrap 0

%if %{with bootstrap}
%global debug_package %{nil}
%endif

%if %{with bootstrap}
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(.*\\)$
%endif

# https://github.com/openshift/osdctl
%global goipath github.com/openshift/osdctl

%global common_description %{expand:
CLI for the OSD utilities.}
Version: @version@

# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
# ---
# New Fedora packages should use %%gometa -f, which makes the package
# ExclusiveArch to %%golang_arches_future and thus excludes the package from
# %%ix86. If the new package is needed as a dependency for another package,
# please consider removing that package from %%ix86 in the same way, instead of
# building more go packages for i686. If your package is not a leaf package,
# you'll need to coordinate the removal of the package's dependents first.
# ---
# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
%gometa -L -f

%global golicenses LICENSE
%global godocs README.md

BuildRequires: git
Name: osdctl
Release: %autorelease
Summary: CLI for the OSD utilities
License: Apache-2.0
URL: %{gourl}
Source: %{gosource}


%description %{common_description}

%gopkg

%prep
%goprep -A

%if %{without bootstrap}
%generate_buildrequires
# %go_generate_buildrequires
%endif

%if %{without bootstrap}
%define gomodulesmode GO111MODULE=on
%build
export GO_LDFLAGS='-X "github.com/openshift/osdctl/pkg/utils.Version="@version@"'
%gobuild -o %{gobuilddir}/bin/osdctl %{goipath}
%endif

%install
%gopkginstall
%if %{without bootstrap}
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
%endif

%if %{without bootstrap}
%if %{with check}
%endif
%endif

%if %{without bootstrap}
%files
%license LICENSE
%doc README.md
%{_bindir}/osdctl
%endif

%gopkgfiles

%changelog
%autochangelog
.
sed \
-e "s/@version@/${version}/g" \
< osdctl.spec.in \
> osdctl.spec
85 changes: 85 additions & 0 deletions hack/osdctl.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Generated by go2rpm 1.15.0
%bcond check 1
%bcond bootstrap 0

%if %{with bootstrap}
%global debug_package %{nil}
%endif

%if %{with bootstrap}
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(.*\\)$
%endif

# https://github.com/openshift/osdctl
%global goipath github.com/openshift/osdctl

%global common_description %{expand:
CLI for the OSD utilities.}
Version: @version@

# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
# ---
# New Fedora packages should use %%gometa -f, which makes the package
# ExclusiveArch to %%golang_arches_future and thus excludes the package from
# %%ix86. If the new package is needed as a dependency for another package,
# please consider removing that package from %%ix86 in the same way, instead of
# building more go packages for i686. If your package is not a leaf package,
# you'll need to coordinate the removal of the package's dependents first.
# ---
# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
%gometa -L -f

%global golicenses LICENSE
%global godocs README.md

BuildRequires: git
Name: osdctl
Release: %autorelease
Summary: CLI for the OSD utilities
License: Apache-2.0
URL: %{gourl}
Source: %{gosource}


%description %{common_description}

%gopkg

%prep
%goprep -A

%if %{without bootstrap}
%generate_buildrequires
# %go_generate_buildrequires
%endif

%if %{without bootstrap}
%define gomodulesmode GO111MODULE=on
%build
export GO_LDFLAGS='-X "github.com/openshift/osdctl/pkg/utils.Version="@version@"'
%gobuild -o %{gobuilddir}/bin/osdctl %{goipath}
%endif

%install
%gopkginstall
%if %{without bootstrap}
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
%endif

%if %{without bootstrap}
%if %{with check}
%endif
%endif

%if %{without bootstrap}
%files
%license LICENSE
%doc README.md
%{_bindir}/osdctl
%endif

%gopkgfiles

%changelog
%autochangelog