Skip to content

Commit 8a0b001

Browse files
committed
ci: add github ci and update woodpecker ci
1 parent 00524c6 commit 8a0b001

5 files changed

Lines changed: 98 additions & 55 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI & Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
create:
7+
tags: [ 'v*' ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
target: x86_64-unknown-linux-gnu
17+
artifact_name: file-rs-x86_64-unknown-linux-gnu
18+
- os: ubuntu-latest
19+
target: x86_64-unknown-linux-musl
20+
artifact_name: file-rs-x86_64-unknown-linux-musl
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install dependencies (musl)
26+
if: matrix.target == 'x86_64-unknown-linux-musl'
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y musl-tools
30+
31+
- name: Setup Rust
32+
uses: dtolnay/rust-toolchain@stable
33+
with:
34+
targets: ${{ matrix.target }}
35+
components: clippy
36+
37+
- name: Rust Cache
38+
uses: Swatinem/rust-cache@v2
39+
40+
- name: Test & Lint
41+
run: |
42+
cargo test --target ${{ matrix.target }}
43+
cargo clippy --target ${{ matrix.target }} -- -D warnings
44+
45+
- name: Build
46+
if: startsWith(github.ref, 'refs/tags/')
47+
run: cargo build --profile optimized --target ${{ matrix.target }}
48+
49+
- name: Package
50+
if: startsWith(github.ref, 'refs/tags/')
51+
run: |
52+
cd target/${{ matrix.target }}/optimized
53+
tar -zcvf ../../../${{ matrix.artifact_name }}.tar.gz file-rs
54+
55+
- name: Upload Artifacts
56+
if: startsWith(github.ref, 'refs/tags/')
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: ${{ matrix.artifact_name }}
60+
path: ${{ matrix.artifact_name }}.tar.gz
61+
62+
release:
63+
needs: build
64+
if: startsWith(github.ref, 'refs/tags/')
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Download all artifacts
68+
uses: actions/download-artifact@v4
69+
70+
- name: Create Release
71+
uses: softprops/action-gh-release@v2
72+
with:
73+
files: "**/*.tar.gz"
74+
name: Release ${{ github.ref_name }}
75+
generate_release_notes: true

.woodpecker.yml

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,49 @@
1+
matrix:
2+
include:
3+
- IMAGE: rust:alpine
4+
TARGET: x86_64-unknown-linux-musl
5+
PKG_UPDATE: apk update
6+
PKG_INSTALL: apk add --no-cache musl-dev
7+
- IMAGE: rust:latest
8+
TARGET: x86_64-unknown-linux-gnu
9+
PKG_UPDATE: apt-get update
10+
PKG_INSTALL: apt-get install -y gcc
11+
112
steps:
213
test:
3-
group: test
414
image: ${IMAGE}
515
environment:
6-
- CARGO_TERM_COLOR=always
7-
- CARGO_BUILD_TARGET=${TARGET}
16+
CARGO_TERM_COLOR: always
817
commands:
9-
- ${PACKAGE_MANAGER} update
10-
- ${PACKAGE_MANAGER} ${INSTALL_CMD} -q ${PACKAGE}
11-
- rustup default stable
18+
- ${PKG_UPDATE}
19+
- ${PKG_INSTALL}
1220
- rustup target add ${TARGET}
21+
- cargo test --target ${TARGET}
1322
- rustup component add clippy
14-
- cargo test --bin file-rs
15-
- cargo clippy
23+
- cargo clippy --target ${TARGET} -- -D warnings
1624

1725
build:
18-
group: build
1926
image: ${IMAGE}
2027
when:
2128
event: tag
2229
environment:
23-
- CARGO_TERM_COLOR=always
24-
- CARGO_BUILD_TARGET=${TARGET}
30+
CARGO_TERM_COLOR: always
2531
commands:
26-
- ${PACKAGE_MANAGER} update
27-
- ${PACKAGE_MANAGER} ${INSTALL_CMD} -q ${PACKAGE}
28-
- rustup default stable
32+
- ${PKG_UPDATE}
33+
- ${PKG_INSTALL}
2934
- rustup target add ${TARGET}
30-
- cargo build --profile optimized
31-
- tar -zcvf file-rs-${TARGET}.tar.gz target/${TARGET}/optimized/file-rs
35+
- cargo build --profile optimized --target ${TARGET}
36+
- tar -zcvf file-rs-${TARGET}.tar.gz -C target/${TARGET}/optimized file-rs
3237

3338
publish:
34-
group: publish
3539
image: woodpeckerci/plugin-gitea-release
3640
when:
3741
event: tag
3842
settings:
3943
base_url: https://codeberg.org
4044
files:
4145
- "file-rs-${TARGET}.tar.gz"
42-
file-exists: overwrite
4346
api_key:
4447
from_secret: CODEBERG_ACCESS_TOKEN
45-
target: main
46-
title: file-rs
47-
skip_verify: true
48-
49-
## only x86_64-unknown-linux-{musl, gnu} is enable for now
50-
matrix:
51-
include:
52-
## musl
53-
- IMAGE: rust:alpine
54-
TARGET: x86_64-unknown-linux-musl
55-
PACKAGE_MANAGER: apk
56-
INSTALL_CMD: add
57-
PACKAGE: musl-dev
58-
# - IMAGE: rust:alpine
59-
# TARGET: aarch64-unknown-linux-musl
60-
# PACKAGE_MANAGER: apk
61-
# INSTALL_CMD: add
62-
# PACKAGE: "gcc-aarch64-none-elf musl-dev binutils-aarch64"
63-
# CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-none-elf-gcc
64-
## gnu/glibc
65-
- IMAGE: rust:latest
66-
TARGET: x86_64-unknown-linux-gnu
67-
PACKAGE_MANAGER: apt
68-
INSTALL_CMD: install
69-
PACKAGE: gcc
70-
# - IMAGE: rust:latest
71-
# TARGET: aarch64-unknown-linux-gnu
72-
# PACKAGE_MANAGER: apt
73-
# INSTALL_CMD: "install -y"
74-
# PACKAGE: "gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu"
75-
# CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
76-
# - TARGET: x86_64-pc-windows-gnu
77-
# IMAGE: rust:latest
78-
# PACKAGE: windows/amd64
79-
# - TARGET: x86_64-pc-windows-msvc
80-
# IMAGE: rust:latest
81-
# PACKAGE: windows/amd64
48+
title: ${CI_COMMIT_TAG}
49+
# skip_verify: true # Only use if Codeberg SSL is flaky

bench1.png

-76.6 KB
Binary file not shown.

bench2.png

-59.1 KB
Binary file not shown.

bench3.png

-72.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)