Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: setup-go
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: '1.22'
go-version: '1.24'
cache: true
cache-dependency-path: go.sum
- name: build
Expand All @@ -27,18 +27,18 @@ jobs:
pull-requests: read # allows the 'only-new-issues' option to work
checks: write # annotate code in the PR
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: setup-go
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: '1.22'
go-version: '1.24'
cache: true
cache-dependency-path: go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@v7.0.0
uses: golangci/golangci-lint-action@v9
with:
install-mode: "binary"
version: "v2.0.2" # matches `golangci-lint --version` in nix devshell
version: "v2.1.6"
# the default behavior as of v7.0.0:
verify: true
- name: go mod tidy
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Install Nix
uses: cachix/install-nix-action@v22
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Install Cache
uses: DeterminateSystems/magic-nix-cache-action@v4
uses: DeterminateSystems/magic-nix-cache-action@v15
- run: nix flake check
# confirms that the shell works, and that there are no linting errors
- name: lint formatting
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: setup-go
uses: actions/setup-go@v4
uses: actions/setup-go@v7
with:
go-version: '1.22'
go-version: '1.24'
cache: true
cache-dependency-path: go.sum
- name: release-darwin-amd64
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.0.0
v3.0.1
12 changes: 11 additions & 1 deletion scripts/golang-ldflags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
VERSION=$1
COMMIT=$2
if [ -z "$VERSION" ]; then
VERSION=$(cat ./VERSION)
base_version=$(tr -d '[:space:]' < ./VERSION)
version_commit=$(git log -n 1 --pretty=format:%H -- ./VERSION 2>/dev/null || true)
if [ -n "$version_commit" ]; then
commits_since=$(git rev-list --count "${version_commit}..HEAD")
else
commits_since=0
fi
major_minor="${base_version%.*}"
base_patch="${base_version##*.}"
patch=$((base_patch + commits_since))
VERSION="${major_minor}.${patch}"
fi
if [ -z "$COMMIT" ]; then
COMMIT="$(git rev-parse --short HEAD || echo '<dev>')"
Expand Down
40 changes: 35 additions & 5 deletions scripts/upsert-gh-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,27 @@
# Docs:
# https://docs.github.com/en/rest/releases/releases#create-a-release
# https://stackoverflow.com/questions/45240336/how-to-use-github-release-api-to-make-a-release-without-source-code
version=$(cat ./VERSION)
commit_sha=$(git rev-parse --short HEAD || echo 'unknown')
# https://semver.org/#spec-item-10
release_name="$version+commit.$commit_sha"
# Read base version from ./VERSION (e.g. v3.0.1) and count commits since ./VERSION
# was last modified to increment the patch between VERSION edits.
base_version=$(tr -d '[:space:]' < ./VERSION)
version_commit=$(git log -n 1 --pretty=format:%H -- ./VERSION 2>/dev/null || true)
if [ -n "$version_commit" ]; then
commits_since=$(git rev-list --count "${version_commit}..HEAD")
else
commits_since=0
fi
# Split "v3.0.1" into "v3.0" (%.*) and "1" (##*.), then offset patch by commit count
major_minor="${base_version%.*}"
base_patch="${base_version##*.}"
patch=$((base_patch + commits_since))

commit_sha=$(git rev-parse --verify HEAD) || exit 1
release_name="${major_minor}.${patch}"
if ! upload_url=$(
gh api --method POST 'repos/{owner}/{repo}/releases' \
-F "tag_name=$release_name" \
-F "name=$release_name" \
-F "target_comitish=$commit_sha" \
-F "target_commitish=$commit_sha" \
--jq '.upload_url' \
); then
if ! upload_url=$(
Expand All @@ -26,6 +38,24 @@ if ! upload_url=$(
exit 1
fi
fi

# Creating a release can also succeed for an existing tag. Resolve the remote
# tag (including annotated tags) before returning any upload URL, so a VERSION
# edit or a concurrent release cannot cause uploads to another commit's release.
if ! tag_commit=$(
gh api --method GET 'repos/{owner}/{repo}/commits/refs/tags/'"$release_name" \
--jq '.sha' \
); then
exit 1
fi

# The release tag must point to the commit we're building; otherwise we'd
# upload this commit's binaries to an older commit's release.
if [ "$tag_commit" != "$commit_sha" ]; then
echo "Release tag $release_name points to $tag_commit, not $commit_sha. Increase VERSION to an unused version." >&2
exit 1
fi

# the upload url looks like
# https://uploads.github.com/.../<release_id>/assets{?name,label}
# this trick strips off the {?name,label}
Expand Down
Loading