Skip to content

Commit 385c838

Browse files
committed
wip
1 parent 6f501fd commit 385c838

File tree

1 file changed

+76
-21
lines changed

1 file changed

+76
-21
lines changed

.github/workflows/ci.yml

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ "release/*" ]
5+
branches: ["feature/ci-add-musl-support", "release/*"]
66
# pull_request:
77
# branches: [ "main" ]
88

@@ -12,25 +12,80 @@ env:
1212
# TODO add musl to CI see DEVELOPMENT.md
1313

1414
jobs:
15-
test_and_publish:
15+
test:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v4
19-
- name: Extra Cargo
20-
run: cargo install cargo-caw-publish
21-
- name: Run tests
22-
run: cargo test
23-
- name: Build
24-
run: cargo build -r --target x86_64-unknown-linux-gnu
25-
- name: Publish to crates.io
26-
env:
27-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
28-
run: cargo caw-publish
29-
- name: Publish to Github Releases
30-
env:
31-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
32-
# TODO https://github.com/rmoraes92/http_status_code_check/actions/runs/13607277508/job/38040223389
33-
run: |
34-
cp target/release/http_status_code_check target/release/http_status_code_check-x86_64-unknown-linux-gnu
35-
ver=$(cat Cargo.toml | grep -e '^version = ".*"$' | sed 's/version = "\(.*\)"/\1/')
36-
gh release create --title v$ver --notes-file RELEASE.md $ver target/release/http_status_code_check-x86_64-unknown-linux-gnu
18+
- name: Checkout Repo
19+
uses: actions/checkout@v4
20+
21+
- name: Run tests
22+
run: cargo test
23+
24+
prepare-release:
25+
needs: test
26+
runs-on: ubuntu-latest
27+
outputs:
28+
pkg_ver: ${{ steps.capture_version_from_cargo.pkg_ver }}
29+
steps:
30+
- name: Checkout Repo
31+
uses: actions/checkout@v4
32+
33+
# TODO create a cargo crate to query data from Cargo.toml
34+
35+
- id: capture_version_from_cargo
36+
name: Capture Version from Cargo.toml
37+
run: |
38+
ver=$(cat Cargo.toml | grep -e '^version = ".*"$' | sed 's/version = "\(.*\)"/\1/')
39+
echo "pkg_ver=$ver" >> "$GITHUB_OUTPUT"
40+
41+
- name: Create Github Release
42+
env:
43+
PKG_VER: ${{ steps.capture_version_from_cargo.outputs.pkg_ver }}
44+
run: |
45+
gh release create \
46+
--title v$PKG_VER --notes-file RELEASE.md $PKG_VER
47+
48+
publish:
49+
needs: prepare-release
50+
name: publish
51+
runs-on: ${{ matrix.os }}
52+
strategy:
53+
matrix:
54+
build:
55+
- linux x86_64
56+
# - linux musl x64
57+
include:
58+
#- build: linux musl x64
59+
# os: ubuntu-latest
60+
# rust: stable
61+
# rust_target: x86_64-unknown-linux-musl
62+
- build: linux gnu x64
63+
os: ubuntu-latest
64+
rust: stable
65+
rust_target: x86_64-unknown-linux-gnu
66+
steps:
67+
- name: Checkout Repo
68+
uses: actions/checkout@v4
69+
70+
- name: Install Dependencies - musl
71+
if: matrix.rust_target == 'x86_64-unknown-linux-musl'
72+
run: sudo apt-get install -y --no-install-recommends musl-tools
73+
74+
- name: Extra Cargo
75+
run: cargo install cargo-caw-publish
76+
77+
- name: Build
78+
run: cargo build -r --target ${{ matrix.rust_target }}
79+
80+
- name: Publish to crates.io
81+
env:
82+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
83+
run: cargo caw-publish
84+
85+
- name: Publish to Github Releases
86+
env:
87+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
88+
PKG_VER: ${{ needs.prepare-release.outputs.pkg_ver }}
89+
run: |
90+
cp target/release/http_status_code_check target/release/http_status_code_check-${{ matrix.rust_target }}
91+
gh release upload $PKG_VER target/release/http_status_code_check-${{ matrix.rust_target }}

0 commit comments

Comments
 (0)