Skip to content

Commit 37549cb

Browse files
committed
Release artifacts
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 5ca832d commit 37549cb

File tree

3 files changed

+112
-2
lines changed

3 files changed

+112
-2
lines changed

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Forked from https://github.com/reproducible-containers/repro-get/blob/v0.2.1/.github/workflows/release.yml
2+
# Forked from https://github.com/containerd/nerdctl/blob/v0.8.1/.github/workflows/release.yml
3+
# Apache License 2.0
4+
5+
name: Release
6+
on:
7+
push:
8+
branches:
9+
- 'master'
10+
tags:
11+
- 'v*'
12+
pull_request:
13+
branches:
14+
- 'master'
15+
jobs:
16+
release:
17+
runs-on: macos-11
18+
timeout-minutes: 20
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
# https://github.com/reproducible-containers/repro-get/issues/3
23+
fetch-depth: 0
24+
ref: ${{ github.event.pull_request.head.sha }}
25+
- name: "Install dependencies"
26+
# coreutils: For `gtouch -d @${SOURCE_DATE_EPOCH}`
27+
# diffoscope: For `make test.repro`
28+
run: brew install coreutils diffoscope
29+
- name: "Test reproducibility"
30+
run: |
31+
make test.repro
32+
git clean -xfd
33+
- name: "Make artifacts"
34+
run: make artifacts
35+
- name: "SHA256SUMS"
36+
run: |
37+
cat _artifacts/SHA256SUMS
38+
- name: "The sha256sum of the SHA256SUMS file"
39+
run: |
40+
(cd _artifacts; shasum -a 256 SHA256SUMS)
41+
- name: "Prepare the release note"
42+
run: |
43+
tag="${GITHUB_REF##*/}"
44+
shasha=$(shasum -a 256 _artifacts/SHA256SUMS | awk '{print $1}')
45+
cat <<-EOF | tee /tmp/release-note.txt
46+
${tag}
47+
48+
(Changes to be documented)
49+
- - -
50+
The binaries were built automatically on GitHub Actions.
51+
The build log is available for 90 days: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
52+
53+
The sha256sum of the SHA256SUMS file itself is \`${shasha}\` .
54+
EOF
55+
- name: "Create release"
56+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: |
60+
tag="${GITHUB_REF##*/}"
61+
asset_flags=()
62+
for f in _artifacts/*; do asset_flags+=("-a" "$f"); done
63+
hub release create "${asset_flags[@]}" -F /tmp/release-note.txt --draft "${tag}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/socket_vmnet
22
/socket_vmnet_client
33
*.o
4+
_artifacts*

Makefile

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
# PREFIX should be only writable by the root to avoid privilege escalation with launchd or sudo
22
PREFIX ?= /opt/socket_vmnet
33

4+
export SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct)
5+
# https://reproducible-builds.org/docs/archives/
6+
TAR ?= gtar --sort=name --mtime="@$(SOURCE_DATE_EPOCH)" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime
7+
TOUCH ?= gtouch -d @$(SOURCE_DATE_EPOCH)
8+
# Not necessary to use GNU's gzip
9+
GZIP ?= gzip -9 -n
10+
DIFFOSCOPE ?= diffoscope
11+
STRIP ?= strip
12+
413
CFLAGS ?= -O3
514

615
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
16+
VERSION_TRIMMED := $(VERSION:v%=%)
717

818
CFLAGS += -DVERSION=\"$(VERSION)\"
919

@@ -37,8 +47,10 @@ socket_vmnet_client: $(patsubst %.c, %.o, $(wildcard client/*.c))
3747

3848
install.bin: socket_vmnet socket_vmnet_client
3949
mkdir -p "$(DESTDIR)/$(PREFIX)/bin"
40-
install socket_vmnet "$(DESTDIR)/$(PREFIX)/bin/socket_vmnet"
41-
install socket_vmnet_client "$(DESTDIR)/$(PREFIX)/bin/socket_vmnet_client"
50+
cp -a socket_vmnet "$(DESTDIR)/$(PREFIX)/bin/socket_vmnet"
51+
cp -a socket_vmnet_client "$(DESTDIR)/$(PREFIX)/bin/socket_vmnet_client"
52+
$(STRIP) "$(DESTDIR)/$(PREFIX)/bin/socket_vmnet"
53+
$(STRIP) "$(DESTDIR)/$(PREFIX)/bin/socket_vmnet_client"
4254

4355
install.doc: README.md LICENSE launchd etc_sudoers.d
4456
mkdir -p "$(DESTDIR)/$(PREFIX)/share/doc/socket_vmnet"
@@ -90,3 +102,37 @@ uninstall: uninstall.launchd.plist uninstall.doc uninstall.bin uninstall.run
90102
.PHONY: clean
91103
clean:
92104
rm -f socket_vmnet socket_vmnet_client *.o client/*.o
105+
106+
define make_artifacts
107+
$(MAKE) clean
108+
rm -rf _artifacts/$(1)
109+
$(MAKE) ARCH=$(1) DESTDIR=_artifacts/$(1) install.bin install.doc
110+
file -bp _artifacts/$(1)/$(PREFIX)/bin/socket_vmnet | grep -q "Mach-O 64-bit executable $(1)"
111+
$(TAR) -C _artifacts/$(1) -cf _artifacts/socket_vmnet-$(VERSION_TRIMMED)-$(1).tar ./
112+
$(GZIP) _artifacts/socket_vmnet-$(VERSION_TRIMMED)-$(1).tar
113+
rm -rf _artifacts/$(1)
114+
$(MAKE) clean
115+
endef
116+
117+
.PHONY: artifacts
118+
artifacts:
119+
rm -rf _artifacts
120+
$(call make_artifacts,x86_64)
121+
$(call make_artifacts,arm64)
122+
sw_vers | tee _artifacts/build-env.txt
123+
echo --- >> _artifacts/build-env.txt
124+
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | tee -a _artifacts/build-env.txt
125+
echo --- >> _artifacts/build-env.txt
126+
$(CC) --version | tee -a _artifacts/build-env.txt
127+
(cd _artifacts ; shasum -a 256 *) > SHA256SUMS
128+
mv SHA256SUMS _artifacts/SHA256SUMS
129+
$(TOUCH) _artifacts/* _artifacts
130+
131+
.PHONY: test.repro
132+
test.repro:
133+
rm -rf _artifacts.0 _artifacts.1
134+
$(MAKE) artifacts
135+
mv _artifacts _artifacts.0
136+
$(MAKE) artifacts
137+
mv _artifacts _artifacts.1
138+
$(DIFFOSCOPE) _artifacts.0/ _artifacts.1/

0 commit comments

Comments
 (0)