-
Notifications
You must be signed in to change notification settings - Fork 65
159 lines (140 loc) · 5.37 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
on:
push:
tags:
- 'v*'
name: Release
jobs:
build:
name: Build
env:
PROJECT_NAME: aderyn
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- name: linux-amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: linux-arm64
runner: ubuntu-latest
target: aarch64-unknown-linux-gnu
- name: win-amd64
runner: windows-latest
target: x86_64-pc-windows-msvc
- name: macos-amd64
runner: macos-latest
target: x86_64-apple-darwin
- name: macos-arm64
runner: macos-latest
target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Extract Tag Name
id: extract_tag_name
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
shell: bash
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.target }}"
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Install Dependencies
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
mkdir -p .cargo
echo '[target.aarch64-unknown-linux-gnu]' > .cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
rustup target add ${{ matrix.target }}
- name: Build Binary
run: cargo build --verbose --locked --release --package aderyn --target ${{ matrix.target }}
- name: Create Binary
shell: bash
run: |
BIN_SUFFIX=""
if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
BIN_SUFFIX=".exe"
fi
BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}"
BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}"
echo "BIN_RELEASE_VERSIONED: $BIN_RELEASE_VERSIONED"
mv "${BIN_OUTPUT}" "./${BIN_RELEASE_VERSIONED}"
echo "BIN_RELEASE_VERSIONED=${BIN_RELEASE_VERSIONED}" >> $GITHUB_ENV
- name: Compress Binary
shell: bash
run: |
mkdir -p compressed
tar -czvf compressed/${{ env.BIN_RELEASE_VERSIONED }}.tar.gz ${{ env.BIN_RELEASE_VERSIONED }}
echo "COMPRESSED_BINARY=compressed/${{ env.BIN_RELEASE_VERSIONED }}.tar.gz" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.BIN_RELEASE_VERSIONED }}.tar.gz
path: ${{ env.COMPRESSED_BINARY }}
outputs:
tag_name: ${{ env.TAG_NAME }}
create_release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.tag_name }}
release_name: "Release ${{ needs.build.outputs.tag_name }}"
draft: true
prerelease: true
- name: Upload Compressed Linux amd64 Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/aderyn-linux-amd64.tar.gz/aderyn-linux-amd64.tar.gz
asset_name: aderyn-linux-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Compressed Linux arm64 Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/aderyn-linux-arm64.tar.gz/aderyn-linux-arm64.tar.gz
asset_name: aderyn-linux-arm64.tar.gz
asset_content_type: application/gzip
- name: Upload Compressed Windows amd64 Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/aderyn-win-amd64.exe.tar.gz/aderyn-win-amd64.exe.tar.gz
asset_name: aderyn-win-amd64.exe.tar.gz
asset_content_type: application/gzip
- name: Upload Compressed MacOS amd64 Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/aderyn-macos-amd64.tar.gz/aderyn-macos-amd64.tar.gz
asset_name: aderyn-macos-amd64.tar.gz
asset_content_type: application/gzip
- name: Upload Compressed MacOS arm64 Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/aderyn-macos-arm64.tar.gz/aderyn-macos-arm64.tar.gz
asset_name: aderyn-macos-arm64.tar.gz
asset_content_type: application/gzip