From 2cf33d97f83d99e847f883c09d1ac03928760ebf Mon Sep 17 00:00:00 2001 From: DeveloperC286 Date: Thu, 21 Dec 2023 11:25:55 +0000 Subject: [PATCH] BUILD: testing release-please * https://github.com/googleapis/release-please * https://github.com/google-github-actions/release-please-action * https://github.com/googleapis/release-please/issues/2096 --- .github/workflows/release-please.yml | 24 +++++++ Earthfile | 26 -------- VERSION | 1 - ci/check-conventional-commits-next-version.sh | 66 ------------------- ci/release.sh | 18 ----- 5 files changed, 24 insertions(+), 111 deletions(-) create mode 100644 .github/workflows/release-please.yml delete mode 100644 VERSION delete mode 100755 ci/check-conventional-commits-next-version.sh delete mode 100755 ci/release.sh diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..4334784 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,24 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v4 + with: + # this assumes that you have created a personal access token + # (PAT) and configured it as a GitHub action secret named + # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important). + token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }} + # this is a built-in strategy in release-please, see "Action Inputs" + # for more options + release-type: simple diff --git a/Earthfile b/Earthfile index 71ef8dd..82416bc 100644 --- a/Earthfile +++ b/Earthfile @@ -11,7 +11,6 @@ COPY_METADATA: COMMAND DO +COPY_CI_DATA COPY ".git" ".git" - COPY "./VERSION" "./VERSION" rust-base: @@ -34,14 +33,6 @@ check-conventional-commits-linting: RUN ./ci/check-conventional-commits-linting.sh --from-reference "${from_reference}" -check-conventional-commits-next-version: - FROM +rust-base - RUN cargo install conventional_commits_next_version --version 6.0.0 - DO +COPY_METADATA - ARG from_reference="origin/HEAD" - RUN ./ci/check-conventional-commits-next-version.sh --from-reference "${from_reference}" - - INSTALL_DEPENDENCIES: COMMAND COPY "go.mod" "go.mod" @@ -205,20 +196,3 @@ unit-test: DO +INSTALL_DEPENDENCIES DO +COPY_SOURCECODE RUN ./ci/unit-test.sh - - -release: - FROM +ubuntu-base - RUN apt-get install wget git -y - # Install GitHub CLI. - ENV GH_VERSION=2.30.0 - RUN wget "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz" - RUN tar -xzvf "gh_${GH_VERSION}_linux_amd64.tar.gz" - RUN cp "./gh_${GH_VERSION}_linux_amd64/bin/gh" /bin/gh - # Install Git Cliff. - ENV GIT_CLIFF_VERSION=1.2.0 - RUN wget "https://github.com/orhun/git-cliff/releases/download/v${GIT_CLIFF_VERSION}/git-cliff-${GIT_CLIFF_VERSION}-x86_64-unknown-linux-gnu.tar.gz" - RUN tar -xzvf "git-cliff-${GIT_CLIFF_VERSION}-x86_64-unknown-linux-gnu.tar.gz" - RUN cp "./git-cliff-${GIT_CLIFF_VERSION}/git-cliff" /bin/git-cliff - DO +COPY_METADATA - RUN --secret GH_TOKEN ./ci/release.sh diff --git a/VERSION b/VERSION deleted file mode 100644 index 3eefcb9..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0.0 diff --git a/ci/check-conventional-commits-next-version.sh b/ci/check-conventional-commits-next-version.sh deleted file mode 100755 index f45155e..0000000 --- a/ci/check-conventional-commits-next-version.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash - -# ARG_OPTIONAL_SINGLE([from-reference],[],[],[origin/HEAD]) -# ARGBASH_GO() -# needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.9.0 one line above ### -# Argbash is a bash code generator used to get arguments parsing right. -# Argbash is FREE SOFTWARE, see https://argbash.io for more info -# Generated online by https://argbash.io/generate - -die() { - local _ret="${2:-1}" - test "${_PRINT_HELP:-no}" = yes && print_help >&2 - echo "$1" >&2 - exit "${_ret}" -} - -begins_with_short_option() { - local first_option all_short_options='' - first_option="${1:0:1}" - test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0 -} - -# THE DEFAULTS INITIALIZATION - OPTIONALS -_arg_from_reference="origin/HEAD" - -print_help() { - printf 'Usage: %s [--from-reference ]\n' "$0" -} - -parse_commandline() { - while test $# -gt 0; do - _key="$1" - case "$_key" in - --from-reference) - test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1 - _arg_from_reference="$2" - shift - ;; - --from-reference=*) - _arg_from_reference="${_key##--from-reference=}" - ;; - *) - _PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1 - ;; - esac - shift - done -} - -parse_commandline "$@" - -# OTHER STUFF GENERATED BY Argbash - -### END OF CODE GENERATED BY Argbash (sortof) ### ]) -# [ <-- needed because of Argbash -set -o errexit -set -o xtrace - -# Get current version. -current_version=$(cat "VERSION") -# Get latest tag. -latest_tag=$(git show "${_arg_from_reference}":VERSION) -# Check current vs expected. -"${CARGO_HOME}/bin/conventional_commits_next_version" --calculation-mode "Batch" --from-reference "${_arg_from_reference}" --from-version "${latest_tag}" --current-version "${current_version}" -# ] <-- needed because of Argbash diff --git a/ci/release.sh b/ci/release.sh deleted file mode 100755 index d1b61ef..0000000 --- a/ci/release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env sh - -set -o errexit -set -o xtrace - -# Get current version. -current_version=$(cat "VERSION") -# If the tag already exist then exit. -git tag -l | grep -q "^${current_version}$" && exit 0 -# Where to start generating the release notes from. -base_commit=$(git rev-list --max-parents=0 HEAD) -# Get the very last tag in the history or else set empty. -latest_tag=$(git describe --exact-match --tags || echo "") -notes_from="${latest_tag:-${base_commit}}" -# Generate the release notes. -release_notes=$(git-cliff "${notes_from}.." --tag "${current_version}" --strip all) -# Create release and the tag. -gh release create "${current_version}" --notes "${release_notes}"