1- # This workflow is for building and pushing reproducible Docker images for releases.
1+ # This workflow is for building and pushing reproducible artifacts for releases
22
33name : release-reproducible
44
55on :
6- push :
7- tags :
8- - v*
6+ workflow_run :
7+ workflows : [release]
8+ types : [completed]
99
1010env :
1111 DOCKER_REPRODUCIBLE_IMAGE_NAME : ghcr.io/${{ github.repository_owner }}/reth-reproducible
1212
1313jobs :
1414 extract-version :
1515 name : extract version
16+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
1617 runs-on : ubuntu-latest
1718 steps :
18- - name : Extract version
19- run : echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT
19+ - name : Extract version from triggering tag
2020 id : extract_version
21+ env :
22+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
23+ run : |
24+ # Get the tag that points to the head SHA of the triggering workflow
25+ TAG=$(gh api /repos/${{ github.repository }}/git/refs/tags \
26+ --jq '.[] | select(.object.sha == "${{ github.event.workflow_run.head_sha }}") | .ref' \
27+ | head -1 \
28+ | sed 's|refs/tags/||')
29+
30+ if [ -z "$TAG" ]; then
31+ echo "No tag found for SHA ${{ github.event.workflow_run.head_sha }}"
32+ exit 1
33+ fi
34+
35+ echo "VERSION=$TAG" >> $GITHUB_OUTPUT
2136 outputs :
2237 VERSION : ${{ steps.extract_version.outputs.VERSION }}
2338
2439 build-reproducible :
25- name : build and push reproducible image
40+ name : build and push reproducible image and binaries
2641 runs-on : ubuntu-latest
27- needs : extract-version
42+ needs : [ extract-version]
2843 permissions :
2944 packages : write
30- contents : read
45+ contents : write
3146 steps :
3247 - uses : actions/checkout@v5
48+ with :
49+ ref : ${{ needs.extract-version.outputs.VERSION }}
50+
3351 - name : Set up Docker Buildx
3452 uses : docker/setup-buildx-action@v3
3553
@@ -40,12 +58,37 @@ jobs:
4058 username : ${{ github.actor }}
4159 password : ${{ secrets.GITHUB_TOKEN }}
4260
43- - name : Build and push reproducible image
61+ - name : Extract Rust version
62+ id : rust_version
63+ run : |
64+ RUST_TOOLCHAIN=$(rustc --version | cut -d' ' -f2)
65+ echo "RUST_TOOLCHAIN=$RUST_TOOLCHAIN" >> $GITHUB_OUTPUT
66+
67+ - name : Build reproducible artifacts
68+ uses : docker/build-push-action@v6
69+ id : docker_build
70+ with :
71+ context : .
72+ file : ./Dockerfile.reproducible
73+ build-args : |
74+ RUST_TOOLCHAIN=${{ steps.rust_version.outputs.RUST_TOOLCHAIN }}
75+ VERSION=${{ needs.extract-version.outputs.VERSION }}
76+ target : artifacts
77+ outputs : type=local,dest=./docker-artifacts
78+ cache-from : type=gha
79+ cache-to : type=gha,mode=max
80+ env :
81+ DOCKER_BUILD_RECORD_UPLOAD : false
82+
83+ - name : Build and push final image
4484 uses : docker/build-push-action@v6
4585 with :
4686 context : .
4787 file : ./Dockerfile.reproducible
4888 push : true
89+ build-args : |
90+ RUST_TOOLCHAIN=${{ steps.rust_version.outputs.RUST_TOOLCHAIN }}
91+ VERSION=${{ needs.extract-version.outputs.VERSION }}
4992 tags : |
5093 ${{ env.DOCKER_REPRODUCIBLE_IMAGE_NAME }}:${{ needs.extract-version.outputs.VERSION }}
5194 ${{ env.DOCKER_REPRODUCIBLE_IMAGE_NAME }}:latest
5497 provenance : false
5598 env :
5699 DOCKER_BUILD_RECORD_UPLOAD : false
100+
101+ - name : Prepare artifacts from Docker build
102+ run : |
103+ mkdir reproducible-artifacts
104+ cp docker-artifacts/reth reproducible-artifacts/reth-reproducible-${{ needs.extract-version.outputs.VERSION }}-x86_64-unknown-linux-gnu
105+ cp docker-artifacts/*.deb reproducible-artifacts/reth-${{ needs.extract-version.outputs.VERSION }}-x86_64-unknown-linux-gnu-reproducible.deb
106+
107+ - name : Configure GPG and create artifacts
108+ env :
109+ GPG_SIGNING_KEY : ${{ secrets.GPG_SIGNING_KEY }}
110+ GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
111+ run : |
112+ export GPG_TTY=$(tty)
113+ echo -n "$GPG_SIGNING_KEY" | base64 --decode | gpg --batch --import
114+
115+ cd reproducible-artifacts
116+ tar -czf reth-reproducible-${{ needs.extract-version.outputs.VERSION }}-x86_64-unknown-linux-gnu.tar.gz reth-reproducible-${{ needs.extract-version.outputs.VERSION }}-x86_64-unknown-linux-gnu --remove-files
117+ echo "$GPG_PASSPHRASE" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch -ab reth-reproducible-${{ needs.extract-version.outputs.VERSION }}-x86_64-unknown-linux-gnu.tar.gz
118+ echo "$GPG_PASSPHRASE" | gpg --passphrase-fd 0 --pinentry-mode loopback --batch -ab reth-${{ needs.extract-version.outputs.VERSION }}-x86_64-unknown-linux-gnu-reproducible.deb
119+
120+ - name : Upload reproducible artifacts to release
121+ env :
122+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
123+ run : |
124+ gh release upload ${{ needs.extract-version.outputs.VERSION }} \
125+ reproducible-artifacts/*
126+
0 commit comments