diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 90cc8a9..6e3e4a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,3 +17,9 @@ jobs: steps: - uses: actions/checkout@master - run: make test + cross: + runs-on: ubuntu-20.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@master + - run: make artifacts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..616df24 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release +on: + push: + tags: + - 'v*' + - 'test-action-release-*' +env: + GO111MODULE: on +jobs: + release: + runs-on: ubuntu-20.04 + timeout-minutes: 20 + steps: + - uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - uses: actions/checkout@v2 + with: + path: go/src/github.com/AkihiroSuda/containerd-fuse-overlayfs + - name: "Compile binaries" + working-directory: go/src/github.com/AkihiroSuda/containerd-fuse-overlayfs + run: make artifacts + - name: "SHA256SUMS" + working-directory: go/src/github.com/AkihiroSuda/containerd-fuse-overlayfs + run: | + ( cd _output; sha256sum containerd-fuse-overlayfs-* ) | tee /tmp/SHA256SUMS + mv /tmp/SHA256SUMS _output/SHA256SUMS + - name: "The sha256sum of the SHA256SUMS file" + working-directory: go/src/github.com/AkihiroSuda/containerd-fuse-overlayfs + run: (cd _output; sha256sum SHA256SUMS) + - name: "Prepare the release note" + working-directory: go/src/github.com/AkihiroSuda/containerd-fuse-overlayfs + run: | + tag="${GITHUB_REF##*/}" + shasha=$(sha256sum _output/SHA256SUMS | awk '{print $1}') + cat <<-EOF | tee /tmp/release-note.txt + ${tag} + + (To be documented) + - - - + The binaries were built automatically on GitHub Actions. + The build log is available for 90 days: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + The sha256sum of the SHA256SUMS file itself is \`${shasha}\` . + EOF + - name: "Create release" + working-directory: go/src/github.com/AkihiroSuda/containerd-fuse-overlayfs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + tag="${GITHUB_REF##*/}" + asset_flags=() + for f in _output/*; do asset_flags+=("-a" "$f"); done + hub release create "${asset_flags[@]}" -F /tmp/release-note.txt --draft "${tag}" diff --git a/.gitignore b/.gitignore index 3c975c1..43be538 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.test bin +/_output diff --git a/Makefile b/Makefile index 677f2c6..54e281d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,17 @@ DESTDIR ?= /usr/local +VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags) +VERSION_TRIMMED := $(VERSION:v%=%) +REVISION=$(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi) + +PKG_MAIN := github.com/AkihiroSuda/containerd-fuse-overlayfs/cmd/containerd-fuse-overlayfs-grpc +PKG_VERSION := github.com/AkihiroSuda/containerd-fuse-overlayfs/cmd/containerd-fuse-overlayfs-grpc/version + +GO ?= go +export GO_BUILD=GO111MODULE=on CGO_ENABLED=0 $(GO) build -ldflags "-s -w -X $(PKG_VERSION).Version=$(VERSION) -X $(PKG_VERSION).Revision=$(REVISION)" + bin/containerd-fuse-overlayfs-grpc: - go build -o $@ ./cmd/containerd-fuse-overlayfs-grpc + $(GO_BUILD) -o $@ $(PKG_MAIN) install: install bin/containerd-fuse-overlayfs-grpc $(DESTDIR)/bin @@ -21,4 +31,19 @@ test: _test: go test -exec rootlesskit -test.v -test.root -.PHONY: bin/containerd-fuse-overlayfs-grpc install uninstall clean test _test +TAR_FLAGS=--transform 's/.*\///g' --owner=0 --group=0 + +artifacts: clean + mkdir -p _output + GOOS=linux GOARCH=amd64 make + tar $(TAR_FLAGS) -czvf _output/containerd-fuse-overlayfs-$(VERSION_TRIMMED)-linux-amd64.tar.gz bin/* + GOOS=linux GOARCH=arm64 make + tar $(TAR_FLAGS) -czvf _output/containerd-fuse-overlayfs-$(VERSION_TRIMMED)-linux-arm64.tar.gz bin/* + GOOS=linux GOARCH=arm GOARM=7 make + tar $(TAR_FLAGS) -czvf _output/containerd-fuse-overlayfs-$(VERSION_TRIMMED)-linux-arm-v7.tar.gz bin/* + GOOS=linux GOARCH=ppc64le make + tar $(TAR_FLAGS) -czvf _output/containerd-fuse-overlayfs-$(VERSION_TRIMMED)-linux-ppc64le.tar.gz bin/* + GOOS=linux GOARCH=s390x make + tar $(TAR_FLAGS) -czvf _output/containerd-fuse-overlayfs-$(VERSION_TRIMMED)-linux-s390x.tar.gz bin/* + +.PHONY: bin/containerd-fuse-overlayfs-grpc install uninstall clean test _test artifacts diff --git a/cmd/containerd-fuse-overlayfs-grpc/main.go b/cmd/containerd-fuse-overlayfs-grpc/main.go index 15200a4..93121c4 100644 --- a/cmd/containerd-fuse-overlayfs-grpc/main.go +++ b/cmd/containerd-fuse-overlayfs-grpc/main.go @@ -23,16 +23,19 @@ import ( "path/filepath" sddaemon "github.com/coreos/go-systemd/v22/daemon" + "github.com/sirupsen/logrus" "google.golang.org/grpc" snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/contrib/snapshotservice" fuseoverlayfs "github.com/AkihiroSuda/containerd-fuse-overlayfs" + "github.com/AkihiroSuda/containerd-fuse-overlayfs/cmd/containerd-fuse-overlayfs-grpc/version" ) // main is from https://github.com/containerd/containerd/blob/b9fad5e310fafb453def5f1e7094f4c36a9806d2/PLUGINS.md func main() { + logrus.Infof("containerd-fuse-overlayfs-grpc Version=%q Revision=%q", version.Version, version.Revision) // Provide a unix address to listen to, this will be the `address` // in the `proxy_plugin` configuration. // The root will be used to store the snapshots. diff --git a/cmd/containerd-fuse-overlayfs-grpc/version/version.go b/cmd/containerd-fuse-overlayfs-grpc/version/version.go new file mode 100644 index 0000000..159c2ae --- /dev/null +++ b/cmd/containerd-fuse-overlayfs-grpc/version/version.go @@ -0,0 +1,23 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package version + +// Version and Revision are filled in Makefile +var ( + Version = "" + Revision = "" +) diff --git a/go.mod b/go.mod index 2716f79..b945950 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7 github.com/coreos/go-systemd/v22 v22.1.0 github.com/pkg/errors v0.9.1 + github.com/sirupsen/logrus v1.7.0 google.golang.org/grpc v1.30.0 )