-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (105 loc) · 3.47 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Release
on:
push:
tags:
- "v*"
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
BINARY_NAME: kustomize-sops
jobs:
build_release:
name: build_release
runs-on: ${{ matrix.image }}
strategy:
matrix:
include:
- os: linux
image: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: linux
image: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: macos
image: macos-latest
target: x86_64-apple-darwin
- os: macos
image: macos-latest
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v2
- name: Install linux
if: ${{ matrix.os == 'linux' }}
run: |
set -ex
sudo apt install musl-tools
rustup target add ${{ matrix.target }}
cargo install cross
- name: Build linux
if: ${{ matrix.os == 'linux' }}
run: cross build --release --target=${{ matrix.target }} --verbose
- name: Install macos
if: ${{ matrix.os == 'macos' }}
run: |
rustup target add ${{ matrix.target }}
- name: Build macos
if: ${{ matrix.os == 'macos' }}
run: cargo build --release --target=${{ matrix.target }} --verbose
- name: Prepare
run: |
final_binary=${{ env.BINARY_NAME }}-${{ matrix.target }}
mv target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} $final_binary
ls
file $final_binary
gzip -f9 $final_binary
- name: Archive binary artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
if-no-files-found: warn
path: |
*.gz
create_release:
name: Create Release
needs: build_release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
upload_release_artifacts:
name: Upload Release Artifacts
needs: create_release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
- target: aarch64-unknown-linux-musl
- target: x86_64-apple-darwin
- target: aarch64-apple-darwin
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./binaries/${{ env.BINARY_NAME }}-${{ matrix.target }}.gz
asset_name: ${{ env.BINARY_NAME }}-${{ matrix.target }}.gz
asset_content_type: application/gzip