-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from truemail-rb/develop
truemail-go v1.0.4
- Loading branch information
Showing
7 changed files
with
148 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,52 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
latest_tag() { | ||
git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | cut -d"-" -f 1 | sort | tail -n 1 | ||
GITHUB_NAMESPACE=$1 | ||
GITHUB_REPOSITORY=$2 | ||
GH_CLI_RELEASES_URL="https://github.com/cli/cli/releases" | ||
FILE_NAME="gh" | ||
BUILD_ARCHITECTURE="linux_amd64.deb" | ||
DELIMETER="_" | ||
PACKAGE_FILE="$FILE_NAME$DELIMETER$BUILD_ARCHITECTURE" | ||
|
||
get_release_candidate_tag() { | ||
git tag --sort=v:refname | grep -E "v[0-9]+\.[0-9]+\.[0-9]+" | tail -n 1 | ||
} | ||
|
||
RELEASE_CANDIDATE_TAG=$(get_release_candidate_tag) | ||
CURRENT_VERSION="$(printf '%s' "$RELEASE_CANDIDATE_TAG" | cut -c 2-2)" | ||
RELEASE_VERSION=$(if [ "$CURRENT_VERSION" -gt 1 ]; then echo "v$CURRENT_VERSION"; else echo; fi) | ||
|
||
release_to_pkg_go() { | ||
echo "Triggering pkg.go.dev about new release..." | ||
curl -X POST "https://pkg.go.dev/fetch/github.com/$GITHUB_NAMESPACE/$GITHUB_REPOSITORY/$RELEASE_VERSION@$RELEASE_CANDIDATE_TAG" | ||
} | ||
|
||
gh_cli_latest_release() { | ||
curl -sL -o /dev/null -w '%{url_effective}' "$GH_CLI_RELEASES_URL/latest" | rev | cut -f 1 -d '/'| rev | ||
} | ||
|
||
download_gh_cli() { | ||
test -z "$VERSION" && VERSION="$(gh_cli_latest_release)" | ||
test -z "$VERSION" && { | ||
echo "Unable to get GitHub CLI release." >&2 | ||
exit 1 | ||
} | ||
curl -s -L -o "$PACKAGE_FILE" "$GH_CLI_RELEASES_URL/download/$VERSION/$FILE_NAME$DELIMETER$(printf '%s' "$VERSION" | cut -c 2-100)$DELIMETER$BUILD_ARCHITECTURE" | ||
} | ||
|
||
install_gh_cli() { | ||
sudo dpkg -i "$PACKAGE_FILE" | ||
rm "$PACKAGE_FILE" | ||
} | ||
|
||
publish_release() { | ||
echo "Triggering pkg.go.dev about new truemail-go release..." | ||
curl -X POST "https://pkg.go.dev/fetch/github.com/truemail-rb/truemail-go@$(latest_tag)" | ||
release_to_github() { | ||
echo "Downloading and installing latest gh cli..." | ||
download_gh_cli | ||
install_gh_cli | ||
echo "Publishing new release notes to GitHub..." | ||
gh release create "$RELEASE_CANDIDATE_TAG" --generate-notes | ||
} | ||
|
||
publish_release | ||
release_to_pkg_go | ||
release_to_github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
SEMVER_REGEX_PATTERN="[0-9]+\.[0-9]+\.[0-9]+" | ||
|
||
latest_changelog_tag() { | ||
grep -Po "(?<=\#\# \[)$SEMVER_REGEX_PATTERN?(?=\])" CHANGELOG.md | head -n 1 | ||
} | ||
|
||
latest_git_tag() { | ||
git tag --sort=v:refname | grep -E "v$SEMVER_REGEX_PATTERN" | tail -n 1 | ||
} | ||
|
||
TAG_CANDIDATE="v$(latest_changelog_tag)" | ||
|
||
if [ "$TAG_CANDIDATE" != "$(latest_git_tag)" ] | ||
then | ||
echo "Configuring git..." | ||
git config --global user.email "${PUBLISHER_EMAIL}" | ||
git config --global user.name "${PUBLISHER_NAME}" | ||
echo "Pushing new semver tag to GitHub..." | ||
git tag "$TAG_CANDIDATE" | ||
git push --tags | ||
echo "Updating develop branch with new semver tag..." | ||
git checkout develop | ||
git merge "$TAG_CANDIDATE" --ff --no-edit | ||
git push origin develop | ||
else | ||
echo "Latest changelog tag ($TAG_CANDIDATE) already released on GitHub. Tagging is not required." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
module github.com/truemail-rb/truemail-go | ||
|
||
go 1.19 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/brianvoe/gofakeit/v6 v6.19.0 | ||
github.com/brianvoe/gofakeit/v6 v6.20.1 | ||
github.com/foxcpp/go-mockdns v1.0.0 | ||
github.com/mocktools/go-smtp-mock/v2 v2.0.1 | ||
github.com/mocktools/go-smtp-mock/v2 v2.0.5 | ||
github.com/stretchr/testify v1.8.1 | ||
golang.org/x/net v0.1.0 | ||
golang.org/x/net v0.7.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/miekg/dns v1.1.50 // indirect | ||
github.com/miekg/dns v1.1.25 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/objx v0.5.0 // indirect | ||
golang.org/x/mod v0.6.0 // indirect | ||
golang.org/x/sys v0.1.0 // indirect | ||
golang.org/x/text v0.4.0 // indirect | ||
golang.org/x/tools v0.2.0 // indirect | ||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392 // indirect | ||
golang.org/x/sys v0.5.0 // indirect | ||
golang.org/x/text v0.7.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters