Skip to content

Commit

Permalink
Merge pull request #47 from onitake/test-artifacts
Browse files Browse the repository at this point in the history
Refactor release process
  • Loading branch information
srgoni authored Apr 5, 2024
2 parents 6a701ca + a2e9b9a commit a93a587
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 102 deletions.
56 changes: 26 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,64 @@
name: Release version
name: Release

on:
push:
tags: "*"
tags: [ "*" ]

permissions:
contents: read

jobs:
build:
name: Release build and run unit tests with Go 1.20
test:
name: Test (Release Go)
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '^1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Check out code
uses: actions/checkout@v4
- name: Test
run: make test

run: make DOCKER=docker release-test
build:
name: Release Build
runs-on: ubuntu-latest
permissions:
# for uploading artifacts
actions: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Build
run: make release

- name: Calculate checksums
run: sha256sum restreamer-* > SHA256SUMS

run: make DOCKER=docker release
- name: Upload artifacts
uses: actions/upload-artifact@v3.1.0
uses: actions/upload-artifact@v4
with:
name: restreamer
path: |
restreamer-*
SHA256SUMS
if-no-files-found: warn
retention-days: 1

release:
name: Release tag
name: Release Tag
runs-on: ubuntu-latest
needs: [build]

needs: [ build, test ]
permissions:
contents: write

steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: restreamer

- name: List artifacts
run: ls -lR

- name: Verify checksums
run: sha256sum -c SHA256SUMS
- name: Construct release version
id: release_version
# remove the leading v (if present) and match the relaxed SemVer part
run: |
export release_version=$(echo ${{ github.ref_name }} | sed -E 's/^v?(([0-9]+.)*[0-9]+)/\1/')
echo "version=${release_version}" >> "${GITHUB_OUTPUT}"
- name: Create GitHub release
uses: swisstxt/github-action-release-artifacts@main
uses: swisstxt/github-action-release-artifacts@v1
with:
tag: ${{ github.ref_name }}
create_release: true
Expand Down
60 changes: 35 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,57 @@
name: Build and test
name: Build + Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
permissions:
contents: read

test-latest:
name: Build and run unit tests with latest Go 1.x
jobs:
test:
name: Build + Test (Latest Go)
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1'

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Check out code
uses: actions/checkout@v4
- name: Build
run: make

- name: Test
run: make test

test-release:
name: Build and run unit tests with Go 1.20
releast-test:
name: Test (Release Go)
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Build
run: make

go-version: '^1'
- name: Check out code
uses: actions/checkout@v4
- name: Test
run: make test
run: make DOCKER=docker release-test
prerelease:
name: Prerelease
runs-on: ubuntu-latest
permissions:
contents: read
# for uploading artifacts
actions: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Release build
run: make DOCKER=docker restreamer-linux-amd64
- name: Upload test artifacts
uses: actions/upload-artifact@v4
with:
name: restreamer-linux-amd64
path: restreamer-linux-amd64
retention-days: 10
overwrite: true
29 changes: 17 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# use go netcode instead of libc
export CGO_ENABLED = 0
# set the build container Go version
GO_VERSION = 1.20
GO_VERSION = 1.22.1
# for overriding the container runtime (needed for GitHub)
DOCKER = podman

# all release binaries to build by default
RELEASE_BINARIES := restreamer-linux-amd64 restreamer-linux-386 restreamer-linux-arm restreamer-linux-arm64 restreamer-darwin-amd64 restreamer-darwin-arm64 restreamer-windows-amd64.exe restreamer-windows-386.exe restreamer-windows-arm64.exe
Expand All @@ -14,7 +16,7 @@ RELEASE_BINARIES := restreamer-linux-amd64 restreamer-linux-386 restreamer-linux
all: restreamer

clean:
rm -rf restreamer ${RELEASE_BINARIES}
rm -rf restreamer SHA256SUMS ${RELEASE_BINARIES}

test:
go vet ./...
Expand All @@ -29,36 +31,39 @@ docker:
restreamer:
go build ./cmd/restreamer

# release builds - use podman to cross-compile to various architectures
# release builds - use container runtime to cross-compile to various architectures

release-test:
$(DOCKER) run -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer:ro -w /go/restreamer golang:${GO_VERSION} sh -c "go vet ./... && go test ./..."

release: SHA256SUMS

SHA256SUMS: $(RELEASE_BINARIES)
sha256sum $^ > $@

restreamer-linux-amd64:
podman run -e GOOS=linux -e GOARCH=amd64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=linux -e GOARCH=amd64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-linux-386:
podman run -e GOOS=linux -e GOARCH=386 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=linux -e GOARCH=386 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-linux-arm:
podman run -e GOOS=linux -e GOARCH=arm -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=linux -e GOARCH=arm -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-linux-arm64:
podman run -e GOOS=linux -e GOARCH=arm64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=linux -e GOARCH=arm64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-darwin-amd64:
podman run -e GOOS=darwin -e GOARCH=amd64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=darwin -e GOARCH=amd64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-darwin-arm64:
podman run -e GOOS=darwin -e GOARCH=arm64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=darwin -e GOARCH=arm64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-windows-amd64.exe:
podman run -e GOOS=windows -e GOARCH=amd64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=windows -e GOARCH=amd64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-windows-386.exe:
podman run -e GOOS=windows -e GOARCH=386 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=windows -e GOARCH=386 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"

restreamer-windows-arm64.exe:
podman run -e GOOS=windows -e GOARCH=arm64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(shell pwd):/go/restreamer -w /go/restreamer golang:${GO_VERSION} go build -o $@ ./cmd/restreamer
$(DOCKER) run -e GOOS=windows -e GOARCH=arm64 -e GOCACHE=/go/.cache -e CGO_ENABLED=0 --rm -v $(abspath .):/go/restreamer -w /go/restreamer golang:${GO_VERSION} sh -c "git config --global --add safe.directory /go/restreamer; go build -o $@ ./cmd/restreamer"
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module github.com/onitake/restreamer

require github.com/prometheus/client_golang v1.16.0
require github.com/prometheus/client_golang v1.19.0

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
golang.org/x/sys v0.8.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
golang.org/x/sys v0.19.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)

go 1.19
go 1.21

toolchain go1.22.1
52 changes: 27 additions & 25 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck=
github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o=
github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=

0 comments on commit a93a587

Please sign in to comment.