Skip to content

Commit 15c6042

Browse files
authored
Release unionpd static binary and docker image (closes #4) (#5)
Example release: https://github.com/unionfi/union/releases/tag/4-include-unionpd-in-release unionpd image: https://github.com/unionfi/union/pkgs/container/unionpd
2 parents 76cd292 + 7f12532 commit 15c6042

File tree

4 files changed

+62
-34
lines changed

4 files changed

+62
-34
lines changed

.github/workflows/release.yml

+44-32
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,52 @@ jobs:
1010
secrets:
1111
nixbuild_token: ${{ secrets.nixbuild_token }}
1212
with:
13-
filter_builds: '(.top_attr == "packages") and (.system == "x86_64-linux" or .system == "aarch64-linux") and (.attr == "uniond" or .attr == "uniond-image")' # ensure to append this list if you want to release more artifacts
13+
filter_builds: '(.top_attr == "packages") and (.system == "x86_64-linux" or .system == "aarch64-linux") and (.attr == "uniond" or .attr == "unionpd" or .attr == "uniond-image" or .attr == "unionpd-image")' # ensure to append this list if you want to release more artifacts
1414

15-
download-docker-images:
15+
dl-images:
1616
runs-on: ubuntu-latest
1717
needs: [build]
1818
permissions: write-all
1919
strategy:
2020
matrix:
21-
package: [ uniond-image ]
21+
package: [ uniond, unionpd ]
2222
system: [ aarch64-linux, x86_64-linux ]
2323
steps:
2424
- uses: actions/download-artifact@v3
2525
with:
26-
name: packages.${{ matrix.system }}.${{ matrix.package }}
26+
name: packages.${{ matrix.system }}.${{ matrix.package }}-image
2727
- uses: nixbuild/nix-quick-install-action@v22
2828
- uses: nixbuild/nixbuild-action@v17
2929
with:
3030
nixbuild_token: ${{ secrets.nixbuild_token }}
3131
- run: mkdir ${{ matrix.system }}
32-
- run: nix copy --to file://`pwd`/${{ matrix.system }} --from ssh-ng://eu.nixbuild.net `cat result.json | jq -r '.packages."${{ matrix.system }}"."${{ matrix.package }}".outputs.out'` --extra-experimental-features nix-command
33-
- run: cat ${{ matrix.system }}/nar/*.nar.xz | xz -dc | nix-store --restore ${{ matrix.system }}.${{ matrix.package }}
32+
- run: nix copy --to file://`pwd`/${{ matrix.system }} --from ssh-ng://eu.nixbuild.net `cat result.json | jq -r '.packages."${{ matrix.system }}"."${{ matrix.package }}-image".outputs.out'` --extra-experimental-features nix-command
33+
- run: cat ${{ matrix.system }}/nar/*.nar.xz | xz -dc | nix-store --restore ${{ matrix.system }}.${{ matrix.package }}-image
3434
- uses: actions/upload-artifact@v3
3535
with:
36-
name: ${{ matrix.system }}.${{ matrix.package }}
37-
path: ${{ matrix.system }}.${{ matrix.package }}
36+
name: ${{ matrix.system }}.${{ matrix.package }}-image
37+
path: ${{ matrix.system }}.${{ matrix.package }}-image
3838
- uses: docker/login-action@v2
3939
with:
4040
registry: ghcr.io
4141
username: ${{ github.actor }}
4242
password: ${{ secrets.GITHUB_TOKEN }}
43-
- run: docker load < ${{ matrix.system }}.uniond-image
44-
- run: docker tag `docker images -q uniond` ghcr.io/unionfi/uniond:${{ github.ref_name }}-${{ matrix.system }}
45-
- run: docker push ghcr.io/unionfi/uniond:${{ github.ref_name }}-${{ matrix.system }}
43+
- run: docker load < ${{ matrix.system }}.${{ matrix.package }}-image
44+
- run: docker tag `docker images -q ${{ matrix.package }}` ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }}-${{ matrix.system }}
45+
- run: docker push ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }}-${{ matrix.system }}
4646

47-
download-static-binaries:
47+
dl-bins:
4848
runs-on: ubuntu-latest
4949
needs: [build]
5050
permissions: write-all
5151
strategy:
5252
matrix:
5353
system: [ aarch64-linux, x86_64-linux ]
54+
package: [ uniond, unionpd ]
5455
steps:
5556
- uses: actions/download-artifact@v3
5657
with:
57-
name: packages.${{ matrix.system }}.uniond
58+
name: packages.${{ matrix.system }}.${{ matrix.package }}
5859
- uses: nixbuild/nix-quick-install-action@v22
5960
- uses: nixbuild/nixbuild-action@v17
6061
with:
@@ -64,54 +65,61 @@ jobs:
6465
- run: ls -la ${{ matrix.system }}
6566
- run: |
6667
echo "Getting OUTPUT and NARINFO_NAME"
67-
OUTPUT=`cat result.json | jq -r '.packages."${{ matrix.system }}".uniond.outputs.out'`
68-
prefix="/nix/store/"
69-
suffix="-uniond" # <- HACK: suffix is hardcoded, change when you want to build a different package
70-
trimmed=${OUTPUT#$prefix}
71-
trimmed=${trimmed%$suffix}
72-
NARINFO_NAME=$trimmed
68+
pwd
69+
cat result.json
70+
OUTPUT=`cat result.json | jq -r '.packages."${{ matrix.system }}"."${{ matrix.package }}".outputs.out'`
71+
NARINFO_NAME=$(basename "$OUTPUT" | cut -d'-' -f1)
72+
echo "OUTPUT = $OUTPUT"
73+
echo "NARINFO_NAME = $NARINFO_NAME"
74+
7375
7476
echo "Copying artifacts from nixbuild.net"
7577
nix copy --to file://`pwd`/${{ matrix.system }} --from ssh-ng://eu.nixbuild.net $OUTPUT --extra-experimental-features nix-command
78+
79+
echo "TREE v"
80+
tree
7681
7782
echo "Get the NAR_URL"
7883
nar_url_line=$(cat ./${{ matrix.system }}/${NARINFO_NAME}.narinfo | grep "URL:")
7984
NAR_URL=$(echo "$nar_url_line" | cut -d " " -f 2-)
8085
8186
echo "Restore the package from the NAR_URL archive"
82-
cat ${{ matrix.system }}/${NAR_URL} | xz -dc | nix-store --restore ${{ matrix.system }}.uniond
83-
mv ${{ matrix.system }}.uniond/bin/uniond uniond-${{ matrix.system }}
87+
cat ${{ matrix.system }}/${NAR_URL} | xz -dc | nix-store --restore ${{ matrix.system }}.${{ matrix.package }}
88+
mv ${{ matrix.system }}.${{ matrix.package }}/bin/${{ matrix.package }} ${{ matrix.package }}-${{ matrix.system }}
8489
8590
echo "DEBUG"
8691
ls -la
8792
tree
8893
- uses: actions/upload-artifact@v3
8994
with:
90-
name: uniond-${{ matrix.system }}
91-
path: uniond-${{ matrix.system }}
95+
name: ${{ matrix.package }}-${{ matrix.system }}
96+
path: ${{ matrix.package }}-${{ matrix.system }}
9297

93-
create-docker-manifest:
98+
docker-manifest:
9499
runs-on: ubuntu-latest
95-
needs: [download-docker-images]
100+
needs: [ dl-images ]
96101
permissions: write-all
102+
strategy:
103+
matrix:
104+
package: [ uniond, unionpd ]
97105
steps:
98106
- uses: docker/login-action@v2
99107
with:
100108
registry: ghcr.io
101109
username: ${{ github.actor }}
102110
password: ${{ secrets.GITHUB_TOKEN }}
103-
- run: docker pull ghcr.io/unionfi/uniond:${{ github.ref_name }}-aarch64-linux
104-
- run: docker pull ghcr.io/unionfi/uniond:${{ github.ref_name }}-x86_64-linux
111+
- run: docker pull ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }}-aarch64-linux
112+
- run: docker pull ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }}-x86_64-linux
105113
- run: |
106114
docker manifest create \
107-
ghcr.io/unionfi/uniond:${{ github.ref_name }} \
108-
--amend ghcr.io/unionfi/uniond:${{ github.ref_name }}-aarch64-linux \
109-
--amend ghcr.io/unionfi/uniond:${{ github.ref_name }}-x86_64-linux \
110-
- run: docker manifest push ghcr.io/unionfi/uniond:${{ github.ref_name }}
115+
ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }} \
116+
--amend ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }}-aarch64-linux \
117+
--amend ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }}-x86_64-linux \
118+
- run: docker manifest push ghcr.io/unionfi/${{ matrix.package }}:${{ github.ref_name }}
111119

112120
release:
113121
runs-on: ubuntu-latest
114-
needs: [create-docker-manifest, download-static-binaries]
122+
needs: [ docker-manifest, dl-bins ]
115123
permissions: write-all
116124
steps:
117125
- uses: actions/download-artifact@v3
@@ -129,6 +137,8 @@ jobs:
129137
files: |
130138
uniond-aarch64-linux
131139
uniond-x86_64-linux
140+
unionpd-aarch64-linux
141+
unionpd-x86_64-linux
132142
- if: "!contains(github.ref_name, 'rc')"
133143
name: 'Create Release'
134144
uses: marvinpinto/[email protected]
@@ -140,3 +150,5 @@ jobs:
140150
files: |
141151
uniond-aarch64-linux
142152
uniond-x86_64-linux
153+
unionpd-aarch64-linux
154+
unionpd-x86_64-linux

.ignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
uniond/vendor
1+
uniond/vendor
2+
unionpd/vendor

uniond/uniond.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
pathsToLink = [ "/bin" ];
3939
};
4040
config = {
41-
Entrypoint = [ "${self'.packages.uniond}/bin/uniond" ];
41+
Entrypoint = [ (pkgs.lib.getExe self'.packages.uniond) ];
4242
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
4343
};
4444
};

unionpd/unionpd.nix

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
];
1616
} else { }));
1717

18+
19+
unionpd-image = pkgs.dockerTools.buildImage {
20+
name = "unionpd";
21+
22+
copyToRoot = pkgs.buildEnv {
23+
name = "image-root";
24+
paths = [ pkgs.coreutils-full pkgs.cacert ];
25+
pathsToLink = [ "/bin" ];
26+
};
27+
config = {
28+
Entrypoint = [ (pkgs.lib.getExe self'.packages.unionpd) ];
29+
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
30+
};
31+
};
32+
1833
generate-prover-proto = pkgs.writeShellApplication {
1934
name = "generate-prover-proto";
2035
runtimeInputs =

0 commit comments

Comments
 (0)