Skip to content

Commit

Permalink
Add release automation on tag push
Browse files Browse the repository at this point in the history
Signed-off-by: David Son <[email protected]>
  • Loading branch information
sondavidb committed Oct 25, 2023
1 parent 104c68c commit a719b65
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
83 changes: 83 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Release

on:
create:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
GO_VERSION: '1.20.6'

permissions:
contents: write
deployments: write

jobs:
# Any way we can just call build.yml?
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- run: make
- run: make test

integration:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
containerd: ["1.6.19", "1.7.0"]
env:
DOCKER_BUILD_ARGS: "CONTAINERD_VERSION=${{ matrix.containerd }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- run: make integration

generate-artifacts:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Setup and export variables
run: |
export release_tag=${GITHUB_REF#refs/*/} # Strip down to raw tag name
export release_version=${release_tag/v/} # Remove v from tag name
echo "dynamic_binary_name=soci-snapshotter-${release_version}-linux-amd64.tar.gz" >> $GITHUB_ENV
echo "static_binary_name=soci-snapshotter-${release_version}-linux-amd64-static.tar.gz" >> $GITHUB_ENV
mkdir release
- name: Create release binaries
run: make RELEASE_TAG=$release_tag release
- uses: actions/upload-artifact@v3
with:
name: artifacts
path: release/
if-no-files-found: error

outputs:
dynamic_binary_name: ${{ env.dynamic_binary_name }}
static_binary_name: ${{ env.static_binary_name }}

create-release:
needs: generate-artifacts
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: artifacts
- uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: false
generate_release_notes: true
files: |
${{ needs.generate-artifacts.outputs.dynamic_binary_name }}
${{ needs.generate-artifacts.outputs.dynamic_binary_name }}.sha256sum
${{ needs.generate-artifacts.outputs.static_binary_name }}
${{ needs.generate-artifacts.outputs.static_binary_name }}.sha256sum
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CMD=soci-snapshotter-grpc soci

CMD_BINARIES=$(addprefix $(OUTDIR)/,$(CMD))

.PHONY: all build check add-ltag install uninstall clean test integration
.PHONY: all build check add-ltag install uninstall clean test integration release

all: build

Expand Down Expand Up @@ -92,6 +92,10 @@ integration: build
@echo "SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT)"
@GO111MODULE=$(GO111MODULE_VALUE) SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT) ENABLE_INTEGRATION_TEST=true go test $(GO_TEST_FLAGS) -v -timeout=0 ./integration

release:
@echo "$@"
@$(SOCI_SNAPSHOTTER_PROJECT_ROOT)/scripts/create-releases.sh $(RELEASE_TAG)

benchmarks:
@echo "$@"
@cd benchmark/performanceTest ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests . && sudo ../bin/PerfTests
Expand Down

0 comments on commit a719b65

Please sign in to comment.