Skip to content

Commit 632aa95

Browse files
committed
Release workflow
1 parent c8c6e15 commit 632aa95

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Prepare release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
create_release:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/create-release@v1
13+
id: create_release
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
tag_name: ${{ github.ref }}
18+
release_name: "checkenv ${{ github.ref_name }}"
19+
body: |
20+
Version ${{ github.ref_name }} of checkenv
21+
draft: true
22+
prerelease: false
23+
outputs:
24+
upload_url: ${{ steps.create_release.outputs.upload_url }}
25+
upload_assets:
26+
runs-on: ubuntu-20.04
27+
needs: create_release
28+
strategy:
29+
fail-fast: true
30+
matrix:
31+
os: ["linux", "darwin", "windows"]
32+
arch: ["386", "amd64", "arm64"]
33+
exclude:
34+
- os: "darwin"
35+
arch: "arm"
36+
- os: "darwin"
37+
arch: "386"
38+
- os: "windows"
39+
arch: "arm"
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: actions/setup-go@v2
43+
with:
44+
go-version: ^1.16.0
45+
- name: Build binary for each valid (GOOS, GOARCH) pair
46+
env:
47+
GOOS: ${{ matrix.os }}
48+
GOARCH: ${{ matrix.arch }}
49+
run: |
50+
BUILD_DIR="checkenv-${{ github.ref_name }}-${GOOS}-${GOARCH}"
51+
EXTENSION=""
52+
if [ "$GOOS" = "windows" ]; then
53+
EXTENSION=".exe"
54+
fi
55+
mkdir "$BUILD_DIR"
56+
cp README.md "$BUILD_DIR/README.md"
57+
go build -o "$BUILD_DIR/checkenv${EXTENSION}" .
58+
zip -r "$BUILD_DIR.zip" "$BUILD_DIR"
59+
- name: Upload release asset for each valid (GOOS, GOARH) pair
60+
uses: actions/upload-release-asset@v1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
upload_url: ${{ needs.create_release.outputs.upload_url }}
65+
asset_path: ./checkenv-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.zip
66+
asset_name: checkenv-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.zip
67+
asset_content_type: application/zip

0 commit comments

Comments
 (0)