Skip to content
Closed
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
36 changes: 10 additions & 26 deletions .github/workflows/release-on-version-bump.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Cut a release when a VERSION bump lands on master.
#
# A maintainer opens a PR bumping the VERSION file (e.g. 0.62.0 -> 0.63.0). Once
# it's approved and merged, this workflow tags v<VERSION>, publishes the GitHub
# release with goreleaser, and kicks the Fedora COPR build. It all runs with the
# built-in GITHUB_TOKEN plus the already-present COPR_URL secret, so there are no
# extra secrets or admin setup required.
# it's approved and merged, this workflow tags v<VERSION> and publishes the
# GitHub release with goreleaser. It all runs with the built-in GITHUB_TOKEN, so
# there are no extra secrets or admin setup required.
#
# The tag, release, and COPR call are done inline here (rather than letting a tag
# push trigger release.yaml / trigger_copr.yaml) because GitHub deliberately does
# not re-trigger workflows for refs pushed by GITHUB_TOKEN. Pushing a v* tag by
# hand still triggers release.yaml and trigger_copr.yaml the normal way.
# The tag and release are done inline here (rather than letting a tag push
# trigger release.yaml) because GitHub deliberately does not re-trigger
# workflows for refs pushed by GITHUB_TOKEN. Pushing a v* tag by hand still
# triggers release.yaml the normal way.
name: release-on-version-bump

on:
Expand Down Expand Up @@ -42,14 +41,14 @@ jobs:
version="$(head -n1 VERSION)"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "VERSION '${version}' must be MAJOR.MINOR.PATCH (e.g. 0.63.0)." >&2
echo "Prerelease/build suffixes are not supported (they break the COPR tag contract)." >&2
echo "Prerelease/build suffixes are not supported." >&2
exit 1
fi
tag="v${version}"
if remote_sha="$(git ls-remote --exit-code origin "refs/tags/${tag}" | cut -f1)"; then
# A tag can exist because a prior run tagged it but failed before
# goreleaser/COPR completed. Only treat it as "already released" if
# it points at the commit we're releasing; otherwise this is a
# goreleaser completed. Only treat it as "already released" if it
# points at the commit we're releasing; otherwise this is a
# conflicting tag and we shouldn't silently skip the release.
if [[ "$remote_sha" == "$(git rev-parse HEAD)" ]]; then
echo "Tag ${tag} already exists at HEAD, nothing to release."
Expand Down Expand Up @@ -90,18 +89,3 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Trigger COPR build
if: steps.version.outputs.skip == 'false'
env:
COPR_URL: ${{ secrets.COPR_URL }}
TAG: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
# --fail + --show-error so an HTTP 4xx/5xx from the webhook fails the
# job instead of silently reporting a successful release.
curl --fail --show-error --connect-timeout 10 --max-time 60 --request POST \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{\"ref_type\": \"tag\", \"ref\": \"${TAG}\"}" \
--url "$COPR_URL"
3 changes: 0 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# with the built-in GITHUB_TOKEN, so no personal token is needed. Tags are
# normally created by release-on-version-bump.yaml (on a VERSION bump), but
# pushing a `v*` tag by hand still works as a fallback.
#
# The existing trigger_copr.yaml workflow also fires on this same tag push, so
# the Fedora COPR build keeps working with no change.
name: release

on:
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/trigger_copr.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ build: ## Compile osdctl
goreleaser build --clean --snapshot --single-target=${SINGLE_TARGET}

# Preferred way to cut a release: bump the VERSION file on a branch and open a PR.
# Once merged to master, GitHub Actions tags vX.Y.Z and publishes the release
# (and triggers the Fedora COPR build). See README "Creating a release".
# Once merged to master, GitHub Actions tags vX.Y.Z and publishes the release.
# See README "Creating a release".
.PHONY: new-release
new-release: ## Bump VERSION for a new release (RELEASE_VERSION=x.y.z), then open a PR
@if [ -z "$(RELEASE_VERSION)" ]; then \
Expand Down
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,17 @@ Releases are automated. Any maintainer can cut a release by opening a PR that bu
You can edit `VERSION` directly, or run `make new-release RELEASE_VERSION=0.63.0` to
bump it for you.
2. Get it reviewed and merged to `master` the usual way (`/lgtm`, `/approve`).
3. On merge, the `release-on-version-bump` workflow tags `vX.Y.Z`, publishes the
GitHub release with `goreleaser`, and kicks the Fedora COPR build.
3. On merge, the `release-on-version-bump` workflow tags `vX.Y.Z` and publishes the
GitHub release with `goreleaser`.

No secrets or admin setup are required: the workflow uses the built-in `GITHUB_TOKEN`
and the `COPR_URL` secret that already powers `trigger_copr_on_tag`. The tag, release,
and COPR call are done inline in one job because GitHub doesn't re-trigger workflows
for tags pushed by `GITHUB_TOKEN`.

#### For Fedora

Fedora releases are built in a COPR repository via a [custom
webhook](https://docs.pagure.org/copr.copr/user_documentation.html#custom-webhook) and the `hack/copr.sh` script as
build method. The automated flow above calls this webhook as part of the release job.
Pushing a `vX.Y.Z` tag by hand instead triggers the `trigger_copr_on_tag` workflow,
which calls the same webhook.
No secrets or admin setup are required: the workflow uses the built-in `GITHUB_TOKEN`.
The tag and release are done inline in one job because GitHub doesn't re-trigger
workflows for tags pushed by `GITHUB_TOKEN`.

#### Manually (fallback)

Pushing a `vX.Y.Z` tag directly still works and triggers the same `release` and COPR
workflows. Push it to the remote that points at `openshift/osdctl` (this is `upstream`
Pushing a `vX.Y.Z` tag directly still works and triggers the same `release` workflow.
Push it to the remote that points at `openshift/osdctl` (this is `upstream`
if you cloned a fork, or `origin` if you cloned `openshift/osdctl` directly), using the
same remote for both commands:

Expand Down
1 change: 0 additions & 1 deletion cmd/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func TestUpgradeRefusesWhenManaged(t *testing.T) {
wantSubstring string
wantErr bool
}{
{"copr", "copr", "dnf upgrade osdctl", false},
{"homebrew", "homebrew", "brew upgrade osdctl", false},
{"unknown", "unknown", "unknown install method", true},
}
Expand Down
117 changes: 0 additions & 117 deletions hack/copr.sh

This file was deleted.

85 changes: 0 additions & 85 deletions hack/osdctl.spec

This file was deleted.

6 changes: 2 additions & 4 deletions pkg/utils/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ var (
// InstallMethod is set at build time via -X ldflags when osdctl is
// built by a package manager. Empty string (default) means the binary
// was built from source or via GoReleaser (GitHub releases).
// Known values: "copr", "homebrew".
// Known values: "homebrew".
InstallMethod string
)

// IsManagedInstall reports whether osdctl was installed via a package
// manager (e.g. COPR/RPM, Homebrew) rather than from a GitHub release.
// manager (e.g. Homebrew) rather than from a GitHub release.
func IsManagedInstall() bool {
return InstallMethod != ""
}
Expand All @@ -43,8 +43,6 @@ func UpgradeInstruction() (string, error) {
switch InstallMethod {
case "":
return "", nil
case "copr":
return "dnf upgrade osdctl", nil
case "homebrew":
return "brew upgrade osdctl", nil
default:
Expand Down
2 changes: 0 additions & 2 deletions pkg/utils/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ func TestIsManagedInstall(t *testing.T) {
want bool
}{
{"empty (GitHub release)", "", false},
{"copr", "copr", true},
{"homebrew", "homebrew", true},
}
for _, tt := range tests {
Expand All @@ -31,7 +30,6 @@ func TestUpgradeInstruction(t *testing.T) {
want string
wantErr bool
}{
{"copr", "copr", "dnf upgrade osdctl", false},
{"homebrew", "homebrew", "brew upgrade osdctl", false},
{"empty", "", "", false},
{"unknown", "unknown", "", true},
Expand Down
Loading