-
Notifications
You must be signed in to change notification settings - Fork 15
165 lines (159 loc) · 5.91 KB
/
c_release.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Release_Automation
on:
push:
tags:
- 'c*.*.*'
workflow_dispatch:
inputs:
main_build_only:
description: "Run non-dockerx builds only"
required: true
default: false
type: boolean
permissions: # added using https://github.com/step-security/secure-repo
contents: read
jobs:
main_build:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./packages/c/sshnpd
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
# os: [ubuntu-latest, macOS-latest, windows-latest]
include:
- os: ubuntu-latest
output-name: sshnp-linux-x64
ext: ''
bundle: 'shell'
- os: macOS-latest
output-name: sshnp-macos-x64
ext: ''
bundle: 'shell'
# - os: macos-14
# output-name: sshnp-macos-arm64
# ext: ''
# bundle: 'shell'
# - os: windows-latest
# output-name: sshnp-windows-x64
# ext: '.exe'
# bundle: 'windows'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# compile binaries
- run: |
cmake -B build -S . -DBUILD_SHARED_LIBS=off -DCMAKE_C_COMPILER=clang
cmake --build build
mkdir tarball
mv build/sshnpd .
# zip the build
- if: ${{ matrix.os == 'macOS-latest' || matrix.os == 'macos-14'}}
run: ditto -c -k --keepParent sshnpd tarball/${{ matrix.output-name }}.zip
- if: ${{ matrix.os == 'ubuntu-latest' }}
run: tar -cvzf tarball/${{ matrix.output-name }}.tgz sshnpd
- if: ${{ matrix.os == 'windows-latest' }}
run: Compress-Archive -Path sshnpd -Destination tarball/${{ matrix.output-name }}.zip
# upload the build
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: ${{ matrix.output-name }}_${{ matrix.compiler }}-${{github.ref_name}}-${{github.run_number}}-${{github.run_attempt}}
path: ./packages/c/sshnpd/tarball
if-no-files-found: error
other_build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/c
strategy:
matrix:
platform: [linux/arm/v7, linux/arm64]
# platform: [linux/arm/v7, linux/arm64, linux/riscv64]
include:
- platform: linux/arm/v7
output-name: sshnpd-linux-arm
- platform: linux/arm64
output-name: sshnpd-linux-arm64
# - platform: linux/riscv64
# output-name: sshnpd-linux-riscv64
steps:
- if: ${{ ! inputs.main_build_only }}
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- if: ${{ ! inputs.main_build_only }}
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- if: ${{ ! inputs.main_build_only }}
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- if: ${{ ! inputs.main_build_only }}
run: |
docker buildx build -t cpswan/sshnpdc -f sshnpd/tools/Dockerfile.package \
--platform ${{ matrix.platform }} -o type=tar,dest=bins.tar .
mkdir tarballs
tar -xvf bins.tar -C tarballs
- if: ${{ ! inputs.main_build_only }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: ${{ matrix.output-name }}-${{github.ref_name}}-${{github.run_number}}-${{github.run_attempt}}
path: ./packages/c/tarballs/${{ matrix.output-name }}.tgz
github-release:
name: >-
Upload artifacts and generate checksums for provenance
needs: [main_build, other_build]
runs-on: ubuntu-latest
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
attestations: write
steps:
- name: Download all the tarballs
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
path: tarballs/
# - name: Generate SBOMs
# run: |
# syft scan file:./packages/dart/sshnoports/pubspec.lock \
# -o 'spdx-json=tarballs/dart_sshnoports_sbom.spdx.json' \
# -o 'cyclonedx-json=tarballs/dart_sshnoports_sbom.cyclonedx.json'
- name: Move packages for signing
run: |
cd tarballs
echo "Before:"
ls -latrR *
mv */*.tgz .
mv */*.zip .
rm -Rf -- */
echo "After:"
ls -latrR *
- name: Generate SHA256 checksums
working-directory: tarballs
run: sha256sum * > checksums.txt
- name: Upload artifacts to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' tarballs/**
--repo '${{ github.repository }}'
- id: hash
name: Pass artifact hashes for SLSA provenance
working-directory: tarballs
run: |
echo "hashes=$(cat checksums.txt | base64 -w0)" >> "$GITHUB_OUTPUT"
- uses: actions/attest-build-provenance@534b352d658f90498fd148d231fdbf88f3886a3a # v1.3.1
with:
subject-path: 'tarballs/**'
provenance:
needs: [github-release]
permissions:
actions: read # Needed for detection of GitHub Actions environment.
id-token: write # Needed for provenance signing and ID
contents: write # Needed for release uploads
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] # 5a775b367a56d5bd118a224a811bba288150a563
with:
base64-subjects: "${{ needs.github-release.outputs.hashes }}"
upload-assets: true