Update to v1.3.7 #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build/Pub Release | |
on: | |
push: | |
tags: | |
- '*' | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# linux | |
- build: linux-64-gnu | |
os: ubuntu-20.04 | |
target: x86_64-unknown-linux-gnu | |
sys-type: linux | |
package-deb: yes | |
- build: linux-aarch64-gnu | |
os: ubuntu-20.04 | |
target: aarch64-unknown-linux-gnu | |
sys-type: linux | |
package-deb: yes | |
- build: linux-i686-gnu | |
os: ubuntu-20.04 | |
target: i686-unknown-linux-gnu | |
sys-type: linux | |
package-deb: yes | |
- build: linux-armv7-gnueabihf | |
os: ubuntu-20.04 | |
target: armv7-unknown-linux-gnueabihf | |
sys-type: linux | |
package-deb: no | |
- build: linux-64-musl | |
os: ubuntu-24.04 | |
target: x86_64-unknown-linux-musl | |
sys-type: linux | |
package-deb: no | |
# win | |
- build: windows | |
os: windows-latest | |
target: i686-pc-windows-msvc | |
sys-type: windows | |
package-deb: no | |
- build: windows | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
sys-type: windows | |
package-deb: no | |
# mac | |
- build: mac-os-64 | |
os: macos-latest | |
target: x86_64-apple-darwin | |
sys-type: mac | |
package-deb: no | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Install linux needed deps | |
if: matrix.sys-type == 'linux' | |
shell: bash | |
run: | | |
if [ "${{ matrix.build }}" = "linux-aarch64-gnu" ]; then | |
sudo apt-get install -y gcc-aarch64-linux-gnu | |
elif [ "${{ matrix.build }}" = "linux-i686-gnu" ]; then | |
sudo apt-get install -y gcc-multilib | |
elif [ "${{ matrix.build }}" = "linux-armv7-gnueabihf" ]; then | |
sudo apt-get install -y gcc-arm-linux-gnueabihf | |
elif [ "${{ matrix.build }}" = "linux-64-musl" ]; then | |
sudo apt-get install -y musl-tools | |
fi | |
- name: Install cargo deb packager | |
if: matrix.package-deb == 'yes' | |
shell: bash | |
run: cargo install cargo-deb | |
- name: Running cargo build | |
shell: bash | |
run: | | |
if [ "${{ matrix.package-deb }}" = "yes" ]; then | |
cargo deb -v --output=target/debian/librespeed-rs-${{ matrix.target }}.deb --target=${{ matrix.target }} | |
else | |
cargo build --release --target ${{ matrix.target }} | |
fi | |
# - name: Build | |
# uses: actions-rs/cargo@v1 | |
# with: | |
# use-cross: true | |
# command: build | |
# args: --verbose --release --target ${{ matrix.target }} | |
- name: Make artifact folder | |
shell: bash | |
run: | | |
binary_name="librespeed-rs" | |
dirname="$binary_name-${{ matrix.target }}" | |
mkdir "$dirname" | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" | |
else | |
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" | |
if [ "${{ matrix.package-deb }}" = "yes" ]; then | |
deb_dirname="deb-$dirname" | |
mkdir "$deb_dirname" | |
mv "target/debian/librespeed-rs-${{ matrix.target }}.deb" "$deb_dirname" | |
fi | |
fi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
overwrite: true | |
name: librespeed-rs-${{ matrix.target }} | |
path: librespeed-rs-${{ matrix.target }} | |
- name: Upload deb artifacts | |
if : matrix.package-deb == 'yes' | |
uses: actions/upload-artifact@v4 | |
with: | |
overwrite: true | |
name: deb-librespeed-rs-${{ matrix.target }} | |
path: deb-librespeed-rs-${{ matrix.target }} | |
container-build-push: | |
name: Build and push Container image | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create the Containerfile | |
run: | | |
# Create a Containerfile dynamically to ensure all elements are correctly included | |
cat <<EOF > Containerfile | |
FROM debian:12-slim | |
WORKDIR /usr/local/bin | |
# Use the Docker TARGETPLATFORM to pass in the platform being built | |
ARG TARGETPLATFORM | |
RUN mkdir -p binary | |
COPY configs.toml configs.toml | |
COPY assets assets | |
COPY librespeed-rs-x86_64-unknown-linux-gnu binary/librespeed-rs-x86_64-unknown-linux-gnu | |
COPY librespeed-rs-aarch64-unknown-linux-gnu binary/librespeed-rs-aarch64-unknown-linux-gnu | |
COPY librespeed-rs-armv7-unknown-linux-gnueabihf binary/librespeed-rs-armv7-unknown-linux-gnueabihf | |
# Match the correct binary based on the platform | |
RUN if [ "\$TARGETPLATFORM" = "linux/amd64" ]; then \ | |
cp binary/librespeed-rs-x86_64-unknown-linux-gnu/librespeed-rs librespeed-rs; \ | |
elif [ "\$TARGETPLATFORM" = "linux/arm64" ]; then \ | |
cp binary/librespeed-rs-aarch64-unknown-linux-gnu/librespeed-rs librespeed-rs; \ | |
elif [ "\$TARGETPLATFORM" = "linux/arm/v7" ]; then \ | |
cp binary/librespeed-rs-armv7-unknown-linux-gnueabihf/librespeed-rs librespeed-rs; \ | |
else \ | |
echo "Unsupported platform: \$TARGETPLATFORM" && exit 1; \ | |
fi | |
RUN rm -rf binary/; chmod +x librespeed-rs; | |
EXPOSE 8080 | |
ENTRYPOINT ["librespeed-rs"] | |
EOF | |
- name: Build container image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
file: ./Containerfile | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
release: | |
needs: [build] | |
name: Publish release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download changelog file(s) | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: . | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Move deb files & clear deb folders | |
shell: bash | |
run: | | |
for dir in */; do | |
if [[ "$dir" == deb-* ]]; then | |
mv "$dir"* . | |
rm -rf "$dir" | |
fi | |
done | |
- name: Copy files & build archives | |
shell: bash | |
run: | | |
for dir in */; do | |
if [ -d "$dir" ]; then | |
dir_name="${dir%/}" | |
cp "configs.toml" "LICENSE.txt" "country_asn.mmdb" "$dir_name" | |
tar -cJf "${dir_name}.tar.xz" -C "$dir_name" . | |
echo "Compressed ${dir_name}.tar.xz" | |
fi | |
done | |
- name: Generate checksums | |
shell: bash | |
run: | | |
md5sum_file() { | |
local file=$1 | |
local checksum=$(md5sum "$file" | awk '{print $1}') | |
local filename=$(basename "$file") | |
echo "$checksum : $filename" >> checksums.txt | |
} | |
rm -f checksums.txt | |
find . -type f -name '*.xz' -or -name '*.zip' -or -name '*.deb' | while read file; do | |
md5sum_file "$file" | |
done | |
- name: Extract release notes | |
run: | | |
awk -v ver="${{ github.ref_name }}" '/^## Version / { if (p) { exit }; if ($3 == ver) { p=1; next } } p && NF' "CHANGELOG.md" > RELEASE_NOTE.txt | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: Release ${{ github.ref_name }} | |
body_path: RELEASE_NOTE.txt | |
files: | | |
*.zip | |
*.xz | |
*.deb | |
checksums.txt |