Skip to content

Commit

Permalink
Add a GHA for building a release
Browse files Browse the repository at this point in the history
  • Loading branch information
nwneisen committed Oct 28, 2023
1 parent 170103f commit a30e473
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 125 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_call:


jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Build
run: make static-linux

- name: Upload
if: ${{ github.event_name == 'release' }}
uses: actions/upload-artifact@v3
with:
name: cri-dockerd
retention-days: 5
path: |
packaging/static/**/**/**/*.tgz
deb:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Build
run: make deb

- name: Upload
uses: actions/upload-artifact@v3
with:
name: cri-dockerd
retention-days: 5
path: |
packaging/deb/**/**/**/*.deb
rpm:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Build
run: make rpm

- name: Upload
uses: actions/upload-artifact@v3
with:
name: cri-dockerd
retention-days: 5
path: |
packaging/rpm/**/**/**/*.rpm
arm:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Build
run: make cross-arm

- name: Upload
uses: actions/upload-artifact@v3
with:
name: cri-dockerd
retention-days: 5
path: |
packaging/static/**/**/**/*.tgz
windows:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Build
run: make cross-win

- name: Upload
if: ${{ github.event_name == 'release' }}
uses: actions/upload-artifact@v3
with:
name: cri-dockerd
retention-days: 5
path: |
packaging/static/**/**/**/*.zip
mac:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Build
run: make cross-mac

- name: Upload
if: ${{ github.event_name == 'release' }}
uses: actions/upload-artifact@v3
with:
name: cri-dockerd
retention-days: 5
path: |
packaging/static/**/**/**/*.tgz
61 changes: 0 additions & 61 deletions .github/workflows/ci.yml

This file was deleted.

8 changes: 2 additions & 6 deletions .github/workflows/hugo.yml → .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
name: Deploy Hugo site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
workflow_call:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -27,7 +25,6 @@ defaults:
shell: bash

jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -63,8 +60,7 @@ jobs:
with:
path: ./docs/public

# Deployment job
deploy:
publish:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_call:

jobs:
e2e-test:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_call:

jobs:
integration:
Expand Down
37 changes: 14 additions & 23 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
name: Build and publish artifacts
name: Publish

on:
release:
types: [created]
workflow_call:

jobs:
releases-matrix:
name: Build and publish static binaries
publish-binaries:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
exclude:
- goarch: "arm64"
goos: windows

steps:
- uses: actions/checkout@v2
- uses: wangyoucao577/[email protected]
- uses: actions/download-artifact@v3
with:
name: cri-dockerd
- name: Push binaries
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
project_path: "./"
binary_name: "cri-dockerd"
pre_command: "export CGO_ENABLED=0"
extra_files: LICENSE README.md
overwrite: true
files: |
**/*.tgz
**/*.rpm
**/*.deb
**/*.zip
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
release:
types: [prereleased]

jobs:
build:
uses: ./.github/workflows/build.yml
e2e:
uses: ./.github/workflows/e2e.yml
integration:
uses: ./.github/workflows/integration.yml
publish:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
needs: [build, e2e, integration]
uses: ./.github/workflows/publish.yml
docs:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
needs: [build, e2e, integration]
uses: ./.github/workflows/docs.yml
31 changes: 0 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,6 @@ clean: ## clean the build artifacts
$(RM) -r build
-$(MAKE) -C $(PACKAGING_DIR) clean

.PHONY: release
release: static deb rpm cross-arm cross-mac cross-win ## build the release binaries
mkdir -p $(RELEASE_DIR)

# Copy the release files
# Debian
cp $(PACKAGING_DIR)/deb/debbuild/debian-bullseye/cri-dockerd_$(VERSION)~3-0~debian-bullseye_amd64.deb $(RELEASE_DIR)
cp $(PACKAGING_DIR)/deb/debbuild/debian-buster/cri-dockerd_$(VERSION)~3-0~debian-buster_amd64.deb $(RELEASE_DIR)
# Ubuntu
cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-bionic/cri-dockerd_$(VERSION)~3-0~ubuntu-bionic_amd64.deb $(RELEASE_DIR)
cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-focal/cri-dockerd_$(VERSION)~3-0~ubuntu-focal_amd64.deb $(RELEASE_DIR)
cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-jammy/cri-dockerd_$(VERSION)~3-0~ubuntu-jammy_amd64.deb $(RELEASE_DIR)
# CentOS
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.el7.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.el8.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.el7.src.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.el8.src.rpm $(RELEASE_DIR)
# Fedora
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.fc35.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.fc36.x86_64.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.fc35.src.rpm $(RELEASE_DIR)
cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.fc36.src.rpm $(RELEASE_DIR)
# arm
cp $(PACKAGING_DIR)/static/build/arm/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).arm64.tgz
# win
cp $(PACKAGING_DIR)/static/build/win/cri-dockerd-$(VERSION).zip $(RELEASE_DIR)/cri-dockerd-$(VERSION).win.amd64.zip
# mac
cp $(PACKAGING_DIR)/static/build/mac/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).darwin.amd64.tgz
# linux
cp $(PACKAGING_DIR)/static/build/linux/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).amd64.tgz

.PHONY: run
run: cri-dockerd ## Run cri-docker in a running minikube
sudo ./cri-dockerd --log-level debug --network-plugin=""
Expand Down
8 changes: 4 additions & 4 deletions packaging/static/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static-linux:
mkdir -p build/linux/cri-dockerd
cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(ARCH) go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd
mv $(APP_DIR)/cri-dockerd build/linux/cri-dockerd/cri-dockerd
tar -C build/linux -c -z -f build/linux/cri-dockerd-$(VERSION).tgz cri-dockerd
tar -C build/linux -c -z -f build/linux/cri-dockerd-$(VERSION).amd64.tgz cri-dockerd

.PHONY: hash_files
hash_files:
Expand All @@ -63,15 +63,15 @@ cross-mac:
mkdir -p build/mac/cri-dockerd
cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=$(ARCH) go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd-darwin-amd64
mv $(APP_DIR)/cri-dockerd-darwin-amd64 build/mac/cri-dockerd/cri-dockerd
tar -C build/mac -c -z -f build/mac/cri-dockerd-$(VERSION).tgz cri-dockerd
tar -C build/mac -c -z -f build/mac/cri-dockerd-$(VERSION).darwin.amd64.tgz cri-dockerd

.PHONY: cross-win
cross-win:
mkdir -p build/win/cri-dockerd
cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=windows GOARCH=$(ARCH) go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd-windows-amd64
mv $(APP_DIR)/cri-dockerd-windows-amd64 build/win/cri-dockerd/cri-dockerd.exe
if ! grep -sq 'docker\|lxc' /proc/1/cgroup; then \
docker run --rm -v $(CURDIR)/build/win:/v -w /v alpine sh -c 'apk update && apk add zip && zip -r cri-dockerd-$(VERSION).zip cri-dockerd'; \
docker run --rm -v $(CURDIR)/build/win:/v -w /v alpine sh -c 'apk update && apk add zip && zip -r cri-dockerd-$(VERSION).win.amd64.zip cri-dockerd'; \
$(CHOWN) -R $(shell id -u):$(shell id -g) build; \
fi

Expand All @@ -80,4 +80,4 @@ cross-arm: ## create tgz with linux arm64 client only
mkdir -p build/arm/cri-dockerd
cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=arm64 go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd-arm64
mv $(APP_DIR)/cri-dockerd-arm64 build/arm/cri-dockerd/cri-dockerd
tar -C build/arm -c -z -f build/arm/cri-dockerd-$(VERSION).tgz cri-dockerd
tar -C build/arm -c -z -f build/arm/cri-dockerd-$(VERSION).arm64.tgz cri-dockerd

0 comments on commit a30e473

Please sign in to comment.