This repository has been archived by the owner on Apr 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
202 lines (197 loc) · 8.43 KB
/
release.yaml
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
name: Release
on:
workflow_dispatch:
push:
branches:
- main
paths:
# Only trigger for new releases
- "version.bzl"
defaults:
run:
shell: bash
env:
BAZEL_STARTUP_FLAGS: --bazelrc=${{ github.workspace }}/.github/github.bazelrc
jobs:
builds:
if: ${{ github.repository_owner == 'abrisco' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Create a job for each target triple
include:
- os: macos-11
env:
TARGET: "aarch64-apple-darwin"
- os: ubuntu-20.04
env:
TARGET: "aarch64-unknown-linux-gnu"
- os: macos-11
env:
TARGET: "x86_64-apple-darwin"
- os: ubuntu-20.04
env:
TARGET: "x86_64-pc-windows-gnu"
- os: windows-2019
env:
TARGET: "x86_64-pc-windows-msvc"
- os: ubuntu-20.04
env:
TARGET: "x86_64-unknown-linux-gnu"
- os: ubuntu-20.04
env:
TARGET: "x86_64-unknown-linux-musl"
steps:
- uses: actions/checkout@v2
with:
ref: "${{ github.base_ref }}"
- name: Install rust toolchains for host
run: |
# Detect the current version of rust
version="$(grep 'RUST_VERSION =' ./WORKSPACE.bazel | sed 's/RUST_VERSION = "//' | sed 's/"//')"
rustup override set "${version}"
rustup update stable && rustup default stable
- name: Setup macos build tooling
run: |
sudo xcode-select -s /Applications/Xcode_12.4.app/Contents/Developer/
# Set SDK environment variables
echo "SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version)" >> $GITHUB_ENV
if: startswith(matrix.os, 'macos')
- name: Setup Windows Bazelrc
run: |
echo "startup --output_user_root=C:/tmp" > ./user.bazelrc
if: startswith(matrix.os, 'Windows')
- name: Build cargo-bazel binaries
run: |
# Build binaries
if [[ "${RUNNER_OS}" == "Windows" ]]; then
OUTPUT_PATH="$(cygpath "${{ github.workspace }}/build/artifacts" -m)"
else
OUTPUT_PATH="${{ github.workspace }}/build/artifacts"
fi
bazel ${BAZEL_STARTUP_FLAGS[@]} run //tools/cross_installer -- --target=${TARGET} --output="${OUTPUT_PATH}"
env:
TARGET: "${{ matrix.env.TARGET }}"
- uses: actions/upload-artifact@v2
with:
name: "${{ matrix.env.TARGET }}"
path: ${{ github.workspace }}/build/artifacts/${{ matrix.env.TARGET }}
if-no-files-found: error
release:
if: ${{ github.repository_owner == 'abrisco' }}
needs: builds
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: main
- uses: actions/download-artifact@v2
with:
path: ${{ github.workspace }}/build/artifacts
- name: Detect the current version
run: |
version="$(grep 'VERSION =' ./version.bzl | sed 's/VERSION = "//' | sed 's/"//')"
echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV
- name: Create the rules archive
run: |
# Update urls and sha256 values
bazel ${BAZEL_STARTUP_FLAGS[@]} run //tools/urls_generator -- --artifacts-dir="${ARTIFACTS_DIR}" --url-prefix="${URL_PREFIX}"
# Publish to a known location
bazel ${BAZEL_STARTUP_FLAGS[@]} run //distro:publish -- ${{ github.workspace }}/build/artifacts
# Save the sha256 checksum of the distro archive to the environment
sha256="$(shasum --algorithm 256 ${{ github.workspace }}/build/artifacts/cargo_bazel.tar.gz | awk '{ print $1 }')"
echo "ARCHIVE_SHA256=${sha256}" >> $GITHUB_ENV
env:
CARGO_BAZEL_GENERATOR_URL: file://${{ github.workspace }}/build/artifacts/x86_64-unknown-linux-gnu/cargo-bazel
ARTIFACTS_DIR: ${{ github.workspace }}/build/artifacts
URL_PREFIX: https://github.com/${{ github.repository_owner }}/cargo-bazel/releases/download/${{env.RELEASE_VERSION}}
- name: Generate release notes
run: |
# Generate the release notes
sed 's/{version}/${{env.RELEASE_VERSION}}/' ${{ github.workspace }}/.github/release_notes.template \
| sed 's/{sha256}/${{env.ARCHIVE_SHA256}}/' \
> ${{ github.workspace }}/.github/release_notes.txt
- uses: actions/create-release@v1
id: cargo_bazel_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{env.RELEASE_VERSION}}
release_name: v${{env.RELEASE_VERSION}}
body_path: ${{ github.workspace }}/.github/release_notes.txt
commitish: ${{ github.base_ref }}
- name: "Upload the rules archive"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo_bazel.tar.gz
asset_path: ${{ github.workspace }}/build/artifacts/cargo_bazel.tar.gz
asset_content_type: application/gzip
# There must be a upload action for each platform triple we create
- name: "Upload aarch64-apple-darwin"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo-bazel-aarch64-apple-darwin
asset_path: ${{ github.workspace }}/build/artifacts/aarch64-apple-darwin/cargo-bazel
asset_content_type: application/octet-stream
- name: "Upload aarch64-unknown-linux-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo-bazel-aarch64-unknown-linux-gnu
asset_path: ${{ github.workspace }}/build/artifacts/aarch64-unknown-linux-gnu/cargo-bazel
asset_content_type: application/octet-stream
- name: "Upload x86_64-apple-darwin"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo-bazel-x86_64-apple-darwin
asset_path: ${{ github.workspace }}/build/artifacts/x86_64-apple-darwin/cargo-bazel
asset_content_type: application/octet-stream
- name: "Upload x86_64-pc-windows-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo-bazel-x86_64-pc-windows-gnu.exe
asset_path: ${{ github.workspace }}/build/artifacts/x86_64-pc-windows-gnu/cargo-bazel.exe
asset_content_type: application/octet-stream
- name: "Upload x86_64-pc-windows-msvc"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo_bazel-x86_64-pc-windows-msvc.exe
asset_path: ${{ github.workspace }}/build/artifacts/x86_64-pc-windows-msvc/cargo-bazel.exe
asset_content_type: application/octet-stream
- name: "Upload x86_64-unknown-linux-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo-bazel-x86_64-unknown-linux-gnu
asset_path: ${{ github.workspace }}/build/artifacts/x86_64-unknown-linux-gnu/cargo-bazel
asset_content_type: application/octet-stream
- name: "Upload x86_64-unknown-linux-musl"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.cargo_bazel_release.outputs.upload_url }}
asset_name: cargo-bazel-x86_64-unknown-linux-musl
asset_path: ${{ github.workspace }}/build/artifacts/x86_64-unknown-linux-musl/cargo-bazel
asset_content_type: application/octet-stream