diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index 0061ae6..48c413e 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -20,16 +20,3 @@ jobs: fetch-depth: 0 - name: Check Conventional Commits linting. run: earthly --ci +check-conventional-commits-linting --from_reference "origin/${{ github.base_ref }}" - next-version: - name: Next Version - runs-on: ubuntu-latest - steps: - - name: Download Earthly v0.7.17. - run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.17/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" - - name: Checkout code. - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - name: Check Conventional Commits next version. - run: earthly --ci +check-conventional-commits-next-version --from_reference "origin/${{ github.base_ref }}" 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/.github/workflows/releasing.yml b/.github/workflows/releasing.yml deleted file mode 100644 index 59738ba..0000000 --- a/.github/workflows/releasing.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Releasing - -on: - push: - branches: [main] - -env: - # Forcing Earthly to use colours, to make reading output easier. - FORCE_COLOR: 1 - -permissions: - # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs - # `write` allows GitHub Actions to create a release. - contents: write - -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Download Earthly v0.7.17. - run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.17/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" - - name: Checkout code. - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Release. - run: earthly --ci --secret GH_TOKEN +release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by GitHub Actions. 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}"