Skip to content

Commit 8c4d2c1

Browse files
committed
hopefully improve github action to create actual releases
1 parent 50b9b3a commit 8c4d2c1

File tree

1 file changed

+83
-29
lines changed

1 file changed

+83
-29
lines changed

.github/workflows/binaries.yaml

Lines changed: 83 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,25 @@ on:
55
push:
66
branches:
77
- ci
8+
tags:
9+
- '*' # build & release on any tag push, e.g. v1.2.3
810
schedule:
911
- cron: "0 0 * * 0"
1012

13+
permissions:
14+
contents: write # required to create releases
15+
1116
jobs:
1217
build:
1318
strategy:
1419
matrix:
1520
config:
16-
- arch: x86-64
17-
config: ARCH=x86-64 PREFIX=/opt/openssh __all__/VERSION=latest
18-
description: x86-64
19-
20-
- arch: x86-64
21-
config: ARCH=x86-64 PREFIX=/opt/openssh SHRINK=SHRINK_LEVEL_RUNTIME __all__/VERSION=latest
22-
description: x86-64-small
23-
24-
- arch: armv7-eabihf
25-
config: ARCH=armv7-eabihf PREFIX=/system/opt/openssh __all__/VERSION=latest
26-
description: armv7-eabihf-android
27-
28-
- arch: armv7-eabihf
29-
config: ARCH=armv7-eabihf PREFIX=/opt/openssh __all__/VERSION=latest
30-
description: armv7-eabihf
31-
32-
- arch: armv7-eabihf
33-
config: ARCH=armv7-eabihf PREFIX=/opt/openssh SHRINK=SHRINK_LEVEL_RUNTIME __all__/VERSION=latest
34-
description: armv7-eabihf-small
35-
36-
- arch: aarch64
37-
config: ARCH=aarch64 PREFIX=/system/opt/openssh __all__/VERSION=latest
38-
description: aarch64-android
21+
- arch: x86_64
22+
config: ARCH=x86-64 PREFIX=/openssh SHRINK=SHRINK_LEVEL_RUNTIME __all__/VERSION=latest
23+
description: x86_64-small
3924

4025
- arch: aarch64
41-
config: ARCH=aarch64 PREFIX=/opt/openssh __all__/VERSION=latest
42-
description: aarch64
43-
44-
- arch: aarch64
45-
config: ARCH=aarch64 PREFIX=/opt/openssh SHRINK=SHRINK_LEVEL_RUNTIME __all__/VERSION=latest
26+
config: ARCH=aarch64 PREFIX=/openssh SHRINK=SHRINK_LEVEL_RUNTIME __all__/VERSION=latest
4627
description: aarch64-small
4728

4829
env:
@@ -55,7 +36,7 @@ jobs:
5536
uses: actions/checkout@v4
5637

5738
- name: Install dependencies
58-
run: sudo apt update && sudo apt install -y upx
39+
run: sudo apt update && sudo apt install -y upx zip
5940

6041
- name: Get number of CPU cores
6142
uses: SimenB/github-actions-cpu-cores@v2
@@ -72,3 +53,76 @@ jobs:
7253
name: ssh-binaries-for-${{ matrix.config.description }}
7354
path: |
7455
output/${{ matrix.config.arch }}/bin/
56+
57+
release:
58+
name: Create GitHub Release (on tag)
59+
needs: build
60+
runs-on: ubuntu-24.04
61+
if: startsWith(github.ref, 'refs/tags/') # only run this job for tag pushes
62+
63+
steps:
64+
- name: Download all build artifacts
65+
uses: actions/download-artifact@v4
66+
with:
67+
path: dist
68+
# NOTE: keep merge-multiple:false (default) so each artifact has its own subdir
69+
70+
- name: Package per-arch into archives
71+
shell: bash
72+
run: |
73+
set -euo pipefail
74+
TAG="${GITHUB_REF_NAME}" # e.g. v1.2.3
75+
mkdir -p release
76+
77+
# For each artifact directory (e.g., "ssh-binaries-for-x86-64-small")
78+
for artifact_dir in dist/*; do
79+
[ -d "$artifact_dir" ] || continue
80+
81+
# Derive a friendly arch label from the artifact name
82+
# Expecting artifact names like "ssh-binaries-for-x86-64-small"
83+
base="$(basename "$artifact_dir")"
84+
arch="${base#ssh-binaries-for-}" # => x86-64-small, aarch64-small, etc.
85+
86+
# Ensure the structure contains bin/
87+
if [ ! -d "$artifact_dir/bin" ]; then
88+
echo "WARN: $artifact_dir has no bin/ directory; skipping"
89+
continue
90+
fi
91+
92+
# Compose archive names
93+
PKG_TGZ="openssh-static-${arch}-${TAG}.tar.gz"
94+
PKG_ZIP="openssh-static-${arch}-${TAG}.zip"
95+
96+
# Create .tar.gz with bin/ contents
97+
tar -C "$artifact_dir" -czf "release/${PKG_TGZ}" bin
98+
99+
# Create .zip with bin/ contents
100+
(cd "$artifact_dir" && zip -r "../../release/${PKG_ZIP}" bin > /dev/null)
101+
102+
done
103+
104+
# Generate SHA256SUMS for all archives
105+
(cd release && sha256sum * > SHA256SUMS.txt)
106+
107+
echo "Release artifacts:"
108+
ls -l release
109+
110+
- name: Create release and upload assets
111+
uses: softprops/action-gh-release@v2
112+
with:
113+
tag_name: ${{ github.ref_name }} # e.g. v1.2.3
114+
name: ${{ github.ref_name }}
115+
body: |
116+
Automated release for ${{ github.ref_name }}.
117+
118+
This release includes per-arch archives of static OpenSSH client binaries (both .tar.gz and .zip).
119+
A SHA256SUMS.txt is provided for verification.
120+
draft: false
121+
prerelease: false
122+
generate_release_notes: true
123+
files: |
124+
release/*.tar.gz
125+
release/*.zip
126+
release/SHA256SUMS.txt
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)