Skip to content
Merged
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
88 changes: 0 additions & 88 deletions .circleci/config.yml

This file was deleted.

60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: go vet
run: go vet ./...

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: staticcheck
run: staticcheck ./...

- name: go test
run: go test -v ./...
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

- name: Install Debian package build dependencies
run: |
sudo apt-get update
sudo apt-get install --yes fakeroot lintian

- name: Install go-bin-deb
env:
GO_BIN_DEB_SHA256: 520eeaee7ebd3a7c317fda0c57a93a56c870d36a0dcee0c3d397807f5ef8b8d4
GO_BIN_DEB_URL: https://github.com/groove-x/go-bin-deb/releases/download/0.0.19%2Bgx11/go-bin-deb-amd64.deb
run: |
curl --fail --location --silent --show-error \
--output "$RUNNER_TEMP/go-bin-deb.deb" "$GO_BIN_DEB_URL"
echo "$GO_BIN_DEB_SHA256 $RUNNER_TEMP/go-bin-deb.deb" | sha256sum --check --strict
dpkg-deb --extract "$RUNNER_TEMP/go-bin-deb.deb" "$RUNNER_TEMP/go-bin-deb"
echo "$RUNNER_TEMP/go-bin-deb/usr/bin" >> "$GITHUB_PATH"

- name: Build Debian packages
run: ./scripts/build-deb.sh "$GITHUB_REF_NAME"

- name: Create GitHub Release
run: gh release create "$GITHUB_REF_NAME" packagecloud_*.deb --generate-notes
env:
GH_TOKEN: ${{ github.token }}
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: go vet
run: go vet ./...

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: staticcheck
run: staticcheck ./...

- name: go test
run: go test -v ./...
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

- name: go build
run: go build && go clean
2 changes: 1 addition & 1 deletion api/v1/packagecloudtest/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func SetupToken(tb testing.TB, ctx context.Context, token string) context.Context {
if token == "" {
tb.Fatalf("empty token")
tb.Skip("PACKAGECLOUD_TOKEN is not set")
}
return packagecloud.WithPackagecloudToken(ctx, token)
}
42 changes: 42 additions & 0 deletions scripts/build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -euo pipefail

if [[ $# -ne 1 ]]; then
echo "usage: $0 <vMAJOR.MINOR.PATCH>" >&2
exit 2
fi

tag=$1
if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "tag must have the form vMAJOR.MINOR.PATCH: $tag" >&2
exit 2
fi
version=${tag#v}

script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
project_dir=$(cd -- "$script_dir/.." && pwd)
cd "$project_dir"

rm -f packagecloud_*.deb

build_and_package() {
local arch=$1 goos=$2 goarch=$3 goarm=$4
local work_dir
work_dir=$(mktemp -d "${TMPDIR:-/tmp}/packagecloud-deb.XXXXXX")
trap 'rm -rf -- "$work_dir"' RETURN

env CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" GOARM="$goarm" \
go build -trimpath -ldflags='-s -w' -o packagecloud .

go-bin-deb generate \
--file deb.json \
--version "$version" \
--arch "$arch" \
--wd "$work_dir" \
--output "$project_dir"
}

build_and_package arm64 linux arm64 ""
build_and_package armhf linux arm 7
build_and_package amd64 linux amd64 ""
Loading