-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.cirrus.yml
117 lines (106 loc) · 3.85 KB
/
.cirrus.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
freebsd_instance:
image: freebsd-13-1-release-amd64
# Test FreeBSD in a full VM on cirrus-ci.com
# The binary will be also built in 32-bit mode, but will execute on a
# 64-bit kernel and in a 64-bit environment. Our tests don't execute
# any of the system's binaries, so the environment shouldn't matter.
task:
name: freebsd-test
only_if: $CIRRUS_TAG == ''
env:
RUSTFLAGS: -Dwarnings
setup_script:
- pkg install -y bash
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh -y --profile minimal --default-toolchain stable
- . $HOME/.cargo/env
- rustup target add i686-unknown-freebsd
- |
echo "~~~~ rustc --version ~~~~"
rustc --version
test_script:
- . $HOME/.cargo/env
- cargo test --all
i686_test_script:
- . $HOME/.cargo/env
- |
cargo test --all --target i686-unknown-freebsd
build_test_script:
- . $HOME/.cargo/env
- |
cargo build --verbose
task:
name: freebsd-release
only_if: $CIRRUS_TAG != ''
env:
RUSTFLAGS: -Dwarnings
GITHUB_TOKEN: ENCRYPTED[88194522be89097926aa4dd5223c3c1c414850f6266a9d5c5d92203a425517ca771403e34683846fd5df61ab0804794f]
setup_script:
- pkg install -y bash jq
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh -y --profile minimal --default-toolchain stable
- . $HOME/.cargo/env
- rustup target add i686-unknown-freebsd
- |
echo "~~~~ rustc --version ~~~~"
rustc --version
build_script: |
. $HOME/.cargo/env
cargo build --verbose --release --target=x86_64-unknown-freebsd
cargo build --verbose --release --target=i686-unknown-freebsd
archive_x86_64_script: |
. $HOME/.cargo/env
staging="paket-$CIRRUS_TAG-x86_64-unknown-freebsd"
mkdir -p "$staging/"
cp "target/x86_64-unknown-freebsd/release/paket" "$staging/"
strip "$staging/paket"
cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$staging/"
tar czf "$staging.tar.gz" "$staging"
archive_i686_script: |
. $HOME/.cargo/env
staging="paket-$CIRRUS_TAG-i686-unknown-freebsd"
mkdir -p "$staging/"
cp "target/i686-unknown-freebsd/release/paket" "$staging/"
strip "$staging/paket"
cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$staging/"
tar czf "$staging.tar.gz" "$staging"
upload_script: |
#!/usr/bin/env bash
set -e
. $HOME/.cargo/env
if [[ "$GITHUB_TOKEN" == "" ]]; then
echo "GitHub access token GITHUB_TOKEN env is not provided!"
exit 1
fi
RETRIES=0
until [ $RETRIES -eq 20 ]
do
echo "Finding the GitHub release associated with '$CIRRUS_TAG' tag..."
CIRRUS_RELEASE=$(curl -sL -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases | jq -c "[ .[] | select( .tag_name | contains(\"$CIRRUS_TAG\")) ] | .[0]" | jq -r '.id')
[[ "$CIRRUS_RELEASE" != "null" ]] && break
RETRIES=$((RETRIES+1))
sleep 30
done
if [[ "$CIRRUS_RELEASE" == "null" ]]; then
echo "Can not find the associated GitHub '$CIRRUS_TAG' release!"
exit 1
fi
echo "GitHub release '$CIRRUS_TAG' found. Preparing asset files to upload..."
file_content_type="application/octet-stream"
files_to_upload=(
paket-$CIRRUS_TAG-i686-unknown-freebsd.tar.gz
paket-$CIRRUS_TAG-x86_64-unknown-freebsd.tar.gz
)
for fpath in "${files_to_upload[@]}"
do
echo "Uploading GitHub release asset '$fpath'..."
name=$(basename "$fpath")
url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=$name"
curl -LX POST \
--data-binary @$fpath \
--header "Authorization: token $GITHUB_TOKEN" \
--header "Content-Type: $file_content_type" \
$url_to_upload
done
echo
echo "GitHub release '$CIRRUS_TAG' assets uploaded successfully."