Build cli v0.15.2 (#684)

This commit is contained in:
Sung 2025-10-05 21:26:12 -07:00 committed by GitHub
commit a62c7f9e93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 108 additions and 25 deletions

58
.github/workflows/release-cli.yml vendored Normal file
View file

@ -0,0 +1,58 @@
name: Release CLI
on:
push:
tags:
- 'cli-v*'
jobs:
release:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '>=1.25.0'
- name: Extract version from tag
id: version
run: |
TAG=${GITHUB_REF#refs/tags/cli-v}
echo "version=$TAG" >> $GITHUB_OUTPUT
echo "Releasing version: $TAG"
- name: Install dependencies
run: make install
- name: Run CLI tests
run: make test-cli
- name: Run E2E tests
run: make test-e2e
- name: Build CLI
run: make version=${{ steps.version.outputs.version }} build-cli
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="cli-v${VERSION}"
# Determine if prerelease (version not matching major.minor.patch)
FLAGS=""
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
FLAGS="--prerelease"
fi
gh release create "$TAG" \
build/cli/*.tar.gz \
build/cli/*_checksums.txt \
$FLAGS \
--title="$TAG" \
--notes="Please see the [CHANGELOG](https://github.com/dnote/dnote/blob/master/CHANGELOG.md)" \
--draft

View file

@ -213,6 +213,11 @@ The following log documentes the history of the CLI project
None
### 0.15.2 - 2025-10-05
* Support for 32bit linux, freebsd amd64, mac arm64.
* Remove Pro.
### 0.15.1 - 2024-02-03
* Upgrade `color` dependency (#660).

View file

@ -95,13 +95,13 @@ endif
@${currentDir}/scripts/release.sh cli $(version) ${cliOutputDir}
.PHONY: release-cli
release-cli-homebrew: clean build-cli
release-cli-homebrew:
ifndef version
$(error version is required. Usage: make version=0.1.0 release-cli)
$(error version is required. Usage: make version=0.1.0 release-cli-homebrew)
endif
@echo "==> releasing cli on Homebrew"
@${currentDir}/scripts/cli/release-homebrew.sh $(version) ${cliOutputDir}
@${currentDir}/scripts/cli/release-homebrew.sh $(version)
.PHONY: release-cli
release-server:

View file

@ -68,9 +68,14 @@ uname_os() {
uname_arch() {
arch=$(uname -m)
case $arch in
case $arch in
x86_64) arch="amd64" ;;
aarch64) arch="arm64" ;;
arm64) arch="arm64" ;;
armv7l) arch="arm" ;;
armv6l) arch="arm" ;;
armv5l) arch="arm" ;;
arm) arch="arm" ;;
x86) arch="386" ;;
i686) arch="386" ;;
i386) arch="386" ;;
@ -86,9 +91,17 @@ check_platform() {
found=1
case "$platform" in
darwin/amd64) found=0;;
# Linux
linux/amd64) found=0 ;;
linux/arm64) found=0 ;;
linux/arm) found=0 ;;
# macOS
darwin/amd64) found=0 ;;
darwin/arm64) found=0 ;;
# Windows
windows/amd64) found=0 ;;
# FreeBSD
freebsd/amd64) found=0 ;;
esac
return $found

View file

@ -126,10 +126,6 @@ func getBaseURL(rawURL string) (string, error) {
}
func getServerDisplayURL(ctx context.DnoteCtx) string {
if ctx.APIEndpoint == "https://api.getdnote.com" {
return "https://www.getdnote.com"
}
baseURL, err := getBaseURL(ctx.APIEndpoint)
if err != nil {
return ""

View file

@ -31,10 +31,6 @@ func TestGetServerDisplayURL(t *testing.T) {
apiEndpoint string
expected string
}{
{
apiEndpoint: "https://api.getdnote.com",
expected: "https://www.getdnote.com",
},
{
apiEndpoint: "https://dnote.mydomain.com/api",
expected: "https://dnote.mydomain.com",

View file

@ -16,7 +16,7 @@
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
*/
//go:build linux || darwin
//go:build linux || darwin || freebsd
package dirs

View file

@ -16,7 +16,7 @@
* along with Dnote. If not, see <https://www.gnu.org/licenses/>.
*/
//go:build linux || darwin
//go:build linux || darwin || freebsd
package dirs

View file

@ -36,7 +36,7 @@ if [[ $1 == v* ]]; then
exit 1
fi
goVersion=go-1.21.x
goVersion=go-1.25.x
get_binary_name() {
platform=$1
@ -57,7 +57,7 @@ build() {
# build binary
destDir="$outputDir/$platform-$arch"
ldflags="-X main.apiEndpoint=https://api.getdnote.com -X main.versionTag=$version"
ldflags="-X main.apiEndpoint=https://localhost:3000/api -X main.versionTag=$version"
tags="fts5"
pushd "$projectDir"
@ -92,7 +92,7 @@ build() {
popd
binaryName=$(get_binary_name "$platform")
mv "$destDir/cli-${platform}-"* "$destDir/$binaryName"
mv "$destDir/cli-"* "$destDir/$binaryName"
# build tarball
tarballName="dnote_${version}_${platform}_${arch}.tar.gz"
@ -113,10 +113,20 @@ if [ -z "$GOOS" ] && [ -z "$GOARCH" ]; then
# install the tool
go install src.techknowlogick.com/xgo@latest
# Linux
build linux amd64
build linux arm64
build linux arm
# macOS
build darwin amd64
build darwin arm64
# Windows
build windows amd64
# FreeBSD
build freebsd amd64
else
build "$GOOS" "$GOARCH" true
fi

View file

@ -10,12 +10,13 @@ if [ ! -d "$cliHomebrewDir" ]; then
fi
version=$1
tarball=$2
echo "version: $version"
echo "tarball: $tarball"
sha=$(shasum -a 256 "$tarball" | cut -d ' ' -f 1)
# Download source tarball and calculate SHA256
source_url="https://github.com/dnote/dnote/archive/refs/tags/cli-v${version}.tar.gz"
echo "Calculating SHA256 for: $source_url"
sha=$(curl -L "$source_url" | shasum -a 256 | cut -d ' ' -f 1)
pushd "$cliHomebrewDir"
@ -25,14 +26,18 @@ git pull origin master
cat > ./Formula/dnote.rb << EOF
class Dnote < Formula
desc "A simple command line notebook for programmers"
desc "Simple command line notebook for programmers"
homepage "https://www.getdnote.com"
url "https://github.com/dnote/dnote/releases/download/cli-v${version}/dnote_${version}_darwin_amd64.tar.gz"
version "${version}"
url "https://github.com/dnote/dnote/archive/refs/tags/cli-v${version}.tar.gz"
sha256 "${sha}"
license "GPL-3.0"
head "https://github.com/dnote/dnote.git", branch: "master"
depends_on "go" => :build
def install
bin.install "dnote"
ldflags = "-s -w -X main.apiEndpoint=https://api.getdnote.com -X main.versionTag=#{version}"
system "go", "build", *std_go_args(ldflags: ldflags), "-tags", "fts5", "./pkg/cli"
end
test do