diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..86030f9aac --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,25 @@ +name: release + +# only execute a release when triggered manually +on: + workflow_dispatch: + +env: + RELEASE_REG_USER: ${{ secrets.REGISTRY_USER }} + RELEASE_REG_PASS: ${{ secrets.REGISTRY_PASS }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: log into quay.io + uses: redhat-actions/podman-login@v1 + with: + username: ${RELEASE_REG_USER} + password: ${RELEASE_REG_PASS} + registry: quay.io + - name: execute release.sh + shell: bash + run: make release TOKEN=${GITHUB_TOKEN} + env: + GITHUB_TOKEN: ${{ .secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index c084350eef..b707d3682a 100644 --- a/Makefile +++ b/Makefile @@ -138,5 +138,5 @@ clean: clean-cross-build release: SOURCE_GIT_TAG=$(RELEASE_PRE)-$(TIMESTAMP) release: - ./scripts/release.sh --token $(TOKEN) --target $(TARGET) --version $(SOURCE_GIT_TAG) + ./scripts/release.sh --token $(TOKEN) --version $(SOURCE_GIT_TAG) .PHONY: release diff --git a/scripts/release.sh b/scripts/release.sh index df6930c5a3..7c227c8865 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -47,10 +47,9 @@ help() { This script provides some simple automation for cutting new releases of Microshift. Use: - ./release.sh --token $(cat /token/path) --target $COMMIT + ./release.sh --token $(cat /token/path) Note: do not use "=" with flag values Inputs: - --target (Required) The commit-ish (hash, tag, or branch) to build a release from. Abbreviated commits are NOT permitted. --token (Required) The github application auth token, use to create a github release. --debug, -d Print generated script values for debugging. --help, -h Print this help text. @@ -65,22 +64,13 @@ DEBUG To test releases against a downstream/fork repository, override GIT_OWNER to forked git org/owner and QUAY_OWNER to your quay.io owner or org. - e.g. GIT_OWNER=my_repo QUAY_OWNER=my_quay_repo ./release.sh --token $(cat /token/path) --target $COMMIT + e.g. GIT_OWNER=my_repo QUAY_OWNER=my_quay_repo ./release.sh --token $(cat /token/path ' } generate_api_release_request() { local is_prerelease="${1:=true}" # (copejon) assume for now that all releases are prerelease, unless otherwise specified - printf '{"tag_name": "%s","target_commitish": "%s","name": "%s","prerelease": %s}' "$VERSION" "$TARGET" "$VERSION" "$is_prerelease" -} - -git_checkout_target() { - target="$1" - [ -z "$(git status --porcelain)" ] || { - printf "The working tree is dirty - commit or stash changes before cutting a release!" >&2 - return 1 - } - git checkout "$target" + printf '{"tag_name": "%s","name": "%s","prerelease": %s}' "$VERSION" "$VERSION" "$is_prerelease" } git_create_release() { @@ -211,14 +201,6 @@ debug() { ######## while [ $# -gt 0 ]; do case "$1" in - "--target") - TARGET="${2:-}" - [[ "${TOKEN:=}" =~ ^-.* ]] || [[ -z "$TARGET" ]] && { - printf "flag $1 requires git commit-ish (branch, tag, hash) value" - exit 1 - } - shift 2 - ;; "--token") TOKEN="${2:-}" [[ "$TOKEN" =~ ^-.* ]] || [[ -z "$TOKEN" ]] && { @@ -260,11 +242,9 @@ RELEASE_IMAGE_TAGS=("$IMAGE_REPO:$VERSION-linux-amd64" "$IMAGE_REPO:$VERSION-lin STAGING_DIR="$ROOT/_output/staging" mkdir -p "$STAGING_DIR" -git_checkout_target "$TARGET" || { git switch -; exit 1; } -build_container_images_artifacts || { git switch -; exit 1; } -STAGE_DIR=$(stage_release_image_binaries) || { git switch -; exit 1; } -push_container_image_artifacts || { git switch -; exit 1; } -push_container_manifest || { git switch -; exit 1; } -UPLOAD_URL="$(git_create_release "$API_DATA" "$TOKEN")" || { git switch -; exit 1; } -git_post_artifacts "$STAGE_DIR" "$UPLOAD_URL" "$TOKEN" || { git switch -; exit 1; } -git switch - +build_container_images_artifacts || exit 1 +STAGE_DIR=$(stage_release_image_binaries) || exit 1 +push_container_image_artifacts || exit 1 +push_container_manifest || exit 1 +UPLOAD_URL="$(git_create_release "$API_DATA" "$TOKEN")" || exit 1 +git_post_artifacts "$STAGE_DIR" "$UPLOAD_URL" "$TOKEN" || exit 1