-
Notifications
You must be signed in to change notification settings - Fork 235
132 lines (121 loc) · 4.41 KB
/
ci.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
name: CI
on:
pull_request:
push:
branches: [main, master]
env:
RUSTFLAGS: "-C debuginfo=0 -D warnings"
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
jobs:
tests:
name: Tests
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
toolchain: [stable, beta, nightly]
include:
- os: macos-latest
MACOS: true
- os: windows-latest
- os: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install linux deps
run: |
sudo apt update
sudo apt install -y --no-install-recommends libasound2-dev pkg-config
if: contains(matrix.os, 'ubuntu')
- name: install ${{ matrix.toolchain }} toolchain
id: install_toolchain
run: rustup toolchain install ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo clippy -- -D warnings
if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest'
- run: |
rustup component add rustfmt
cargo fmt --all -- --check
if: matrix.toolchain == 'stable' && matrix.os == 'ubuntu-latest'
- run: cargo test --all-targets
- run: cargo test --features=symphonia-all --all-targets
cargo-yank:
env:
CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Run cargo yank
continue-on-error: true
run: |
RODIO_TMP=$(mktemp /tmp/rodioXXX.txt) || echo "::error::mktemp error"
echo "RODIO_TMP=$RODIO_TMP" >> $GITHUB_ENV
cargo yank --version 0.20.0 --token $CRATESIO_TOKEN 2> $RODIO_TMP
cargo-publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update apt
run: sudo apt update
- name: Install alsa
run: sudo apt install -y --no-install-recommends libasound2-dev pkg-config
- name: Run cargo publish for rodio
continue-on-error: true
run: |
RODIO_TMP=$(mktemp /tmp/rodioXXX.txt) || echo "::error::mktemp error"
echo "RODIO_TMP=$RODIO_TMP" >> $GITHUB_ENV
cargo publish --token $CRATESIO_TOKEN 2> $RODIO_TMP
- name: Check if rodio is already published
run: |
empty=0
RODIO_TMP="${{ env.RODIO_TMP }}"
grep -q '[^[:space:]]' < $RODIO_TMP || empty=1
[ $empty -eq 0 ] && cat $RODIO_TMP
[ $empty -eq 1 ] || grep -q "is already uploaded" < $RODIO_TMP
create-git-tag:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Check if WORKFLOW_TOKEN is set
run: |
if [ -z "${{ secrets.WORKFLOW_TOKEN }}" ]; then
echo "Personal access token WORKFLOW_TOKEN is not set"
exit 1
else
echo "Checked `WORKFLOW_TOKEN` is set"
fi
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history to list all existing tags
token: ${{ secrets.WORKFLOW_TOKEN }}
- name: Extract version from Cargo.toml
id: extract_version
run: |
version=$(awk '/\[package\]/,/^version/ { if ($1 == "version") { gsub(/"/, "", $3); print $3 } }' Cargo.toml)
echo "Version value found: $version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
version=${{ steps.extract_version.outputs.version }}
version_name="v$version"
if git rev-parse "refs/tags/$version_name" >/dev/null 2>&1; then
echo "Tag $version_name already exists"
echo "tag_exists=true" >> $GITHUB_OUTPUT
else
echo "Tag $version_name does not exist"
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
- name: Create and push tag
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
version=${{ steps.extract_version.outputs.version }}
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
version_name="v$version"
git tag -a "$version_name" -m "Release for $version_name"
git push origin $version_name