-
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (133 loc) · 4.46 KB
/
rust.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
133
134
135
name: Rust builds
on:
push:
branches: [main]
tags:
- v*
pull_request:
branches: [main]
permissions:
contents: write
id-token: write
attestations: write
actions: read
jobs:
create-release:
needs:
- build
- nixbuild
- create-sbom
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Rename and move artifacts
run: |
for dir in artifacts/*/
do
dir=${dir%*/} # remove the trailing "/"
for file in $dir/*
do
file=${file##*/} # remove the path before the filename
base=${file%.*} # remove the extension
ext=${file#"$base"} # remove the filename before the extension
echo "moving ${dir}/${file} to artifacts/${file%%.*}-${dir##*/}${ext}"
mv "${dir}/${file}" "artifacts/${file%%.*}-${dir##*/}${ext}"
done
rm -r "${dir}"
done
mv artifacts/sbom.spdx.json sbom.spdx.json
- uses: actions/attest-sbom@v1
with:
subject-path: artifacts/*
subject-name: "counter@${{ github.ref_name }}"
sbom-path: "sbom.spdx.json"
push-to-registry: false
- name: release
uses: ncipollo/release-action@v1
id: create_release
with:
generateReleaseNotes: true
artifacts: "artifacts/*"
nixbuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-23.05
- uses: DeterminateSystems/magic-nix-cache-action@v3
- run: nix-build
- run: nix-shell --run "echo OK"
create-sbom:
runs-on: ubuntu-latest
steps:
- uses: anchore/sbom-action@v0
with:
artifact-name: "sbom.spdx.json"
output-file: "sbom.spdx.json"
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [stable]
target: [x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc, i686-pc-windows-msvc, x86_64-apple-darwin, aarch64-apple-darwin] #x86_64-unknown-linux-musl,
package: ["counter"]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: linux_64-bit
#- os: ubuntu-latest
# target: x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
name: windows_64-bit
- os: windows-latest
target: i686-pc-windows-msvc
name: windows_32-bit
- os: macos-latest
target: x86_64-apple-darwin
name: macos_64-bit
- os: macos-latest
target: aarch64-apple-darwin
name: macos_aarch64
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
cache-target: release
targets: ${{ matrix.target }}
- name: Linux Specific libs install
if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: librust-atk-dev libglib2.0-dev libgtk-3-dev
execute_install_scripts: true
- name: Configure sccache env var and set build profile to ephemeral build
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run build
run: cargo build --target ${{ matrix.target }} --release --package ${{ matrix.package }} --bin ${{ matrix.package }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.package }}-${{ matrix.name }}"
path: |
target/${{ matrix.target }}/release/${{ matrix.package }}*
!target/${{ matrix.target }}/release/deps
!target/${{ matrix.target }}/release/build
!target/${{ matrix.target }}/release/.fingerprint
!target/${{ matrix.target }}/release/examples
!target/${{ matrix.target }}/release/incremental
!target/${{ matrix.target }}/release/.cargo-lock
!target/${{ matrix.target }}/release/*.d
!target/${{ matrix.target }}/release/*.pdb