Skip to content

Commit 115532c

Browse files
authored
Merge pull request #187 from yuchen0cc/main
workflow: support multi-arch release
2 parents 41d63a9 + 36a0412 commit 115532c

File tree

5 files changed

+127
-95
lines changed

5 files changed

+127
-95
lines changed

.github/workflows/develop-release.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
10+
env:
11+
GO_VERSION: "1.19"
12+
13+
jobs:
14+
build:
15+
name: "Build Release"
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Set Release Version
19+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
20+
shell: bash
21+
run: |
22+
releasever=${{ github.ref }}
23+
releasever="${releasever#refs/tags/}"
24+
echo "RELEASE_VERSION=${releasever}" >> $GITHUB_ENV
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 100
29+
- name: Setup buildx instance
30+
uses: docker/setup-buildx-action@v2
31+
with:
32+
use: true
33+
- name: Build
34+
shell: bash
35+
run: |
36+
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
37+
if [[ -z ${RELEASE_VERSION} ]]; then
38+
git fetch --tags
39+
RELEASE_VERSION=$(git tag -l v* | tail -1)
40+
fi
41+
echo "RELEASE_VERSION=${RELEASE_VERSION}"
42+
docker buildx build --build-arg RELEASE_VERSION=${RELEASE_VERSION} --build-arg GO_VERSION=${{ env.GO_VERSION }} -f .github/workflows/release/Dockerfile --platform=linux/amd64,linux/arm64 -o releases/ .
43+
ls -l releases/*/
44+
- name: Upload
45+
uses: actions/upload-artifact@v3
46+
with:
47+
name: releases
48+
path: releases/*/overlaybd-snapshotter*
49+
50+
dev-release:
51+
name: "Development Release"
52+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')
53+
runs-on: ubuntu-latest
54+
needs: [build]
55+
steps:
56+
- name: Download builds and release notes
57+
uses: actions/download-artifact@v3
58+
- name: Display downloaded files
59+
shell: bash
60+
run: ls -l releases/*/
61+
- name: Create Release
62+
uses: "marvinpinto/action-automatic-releases@latest"
63+
with:
64+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
65+
automatic_release_tag: "latest"
66+
prerelease: true
67+
title: "Development Build"
68+
files: |
69+
releases/*/overlaybd-snapshotter*
70+
71+
release:
72+
name: "Tagged Release"
73+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
74+
runs-on: ubuntu-latest
75+
needs: [build]
76+
steps:
77+
- name: Download builds and release notes
78+
uses: actions/download-artifact@v3
79+
- name: Display downloaded files
80+
shell: bash
81+
run: ls -l releases/*/
82+
- name: Create Release
83+
uses: "marvinpinto/action-automatic-releases@latest"
84+
with:
85+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
86+
prerelease: false
87+
files: |
88+
releases/*/overlaybd-snapshotter*

.github/workflows/release/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright The Accelerated Container Image Authors
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG GO_VERSION
16+
ARG GO_IMAGE=golang:${GO_VERSION}
17+
FROM --platform=${BUILDPLATFORM} ${GO_IMAGE} AS builder
18+
WORKDIR /src/github.com/containerd/accelerated-container-image
19+
COPY . .
20+
ENV DEBIAN_FRONTEND=noninteractive
21+
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list && \
22+
apt update && \
23+
apt install -y nfpm && \
24+
go mod tidy
25+
26+
ARG TARGETOS TARGETARCH
27+
ENV GOOS=${TARGETOS}
28+
ENV GOARCH=${TARGETARCH}
29+
ARG RELEASE_VERSION
30+
ENV SEMVER=${RELEASE_VERSION}
31+
RUN make && \
32+
nfpm pkg --packager deb --target /tmp/ && \
33+
nfpm pkg --packager rpm --target /tmp/
34+
35+
FROM scratch AS release
36+
COPY --from=builder /tmp/* /

.github/workflows/tag-release.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

nfpm.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# check https://nfpm.goreleaser.com/configuration for detailed usage
44
#
55
name: "overlaybd-snapshotter"
6-
arch: "amd64"
7-
platform: "linux"
8-
version: "v0.6.1"
6+
arch: ${GOARCH}
7+
platform: ${GOOS}
8+
version: ${SEMVER}
99
section: "default"
1010
priority: "extra"
1111

0 commit comments

Comments
 (0)