@@ -2,14 +2,23 @@ name: Rex Release
22
33on :
44 push :
5+ # On tags, this generates a release and pushes docker images with the tag name
56 tags :
6- - " v[0-9]+.[0-9]+.[0-9]+-*"
7- - " v[0-9]+.[0-9]+.[0-9]+"
7+ - " v*.*.*-*"
8+ # On pushes to main, this silently builds and pushes docker images tagged as 'main'
9+ branches :
10+ - main
11+ workflow_dispatch :
812
913permissions :
1014 contents : write
1115 packages : write
16+ actions : write
1217
18+ env :
19+ REGISTRY : ghcr.io
20+ IMAGE_NAME : ${{ github.repository }}
21+ PROVER_REPRODUCIBLE_BUILD : true
1322
1423jobs :
1524 build-rex :
@@ -34,25 +43,71 @@ jobs:
3443 - name : Checkout code
3544 uses : actions/checkout@v4
3645
37- - name : Rustup toolchain install
38- uses : dtolnay/rust-toolchain@master
39- with :
40- toolchain : ${{ vars.RUST_VERSION }}
46+ - name : Free Disk Space
47+ if : ${{ matrix.os == 'linux' }}
48+ uses : ./.github/actions/free-disk
49+
50+ - name : Setup Rust Environment
51+ uses : ./.github/actions/setup-rust
4152
4253 - name : Build rex
4354 run : |
4455 cargo build --release --bin rex
45- mv target/release/rex rex-${{ matrix.os }}_${{ matrix.arch }}
56+ chmod +x target/release/rex
57+ mv target/release/rex rex-${{ matrix.os }}-${{ matrix.arch }}
4658
4759 - name : Upload artifact
4860 uses : actions/upload-artifact@v4
4961 with :
50- name : rex-${{ matrix.os }}_${{ matrix.arch }}
51- path : rex-${{ matrix.os }}_${{ matrix.arch }}
62+ name : rex-${{ matrix.os }}-${{ matrix.arch }}
63+ path : rex-${{ matrix.os }}-${{ matrix.arch }}
64+
65+ build-docker :
66+ name : " Build and publish rex docker image"
67+ runs-on : ubuntu-latest
5268
69+ # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
70+ permissions :
71+ contents : read
72+ packages : write
73+ attestations : write
74+ id-token : write
75+ actions : write
76+
77+ steps :
78+ - name : Checkout code
79+ uses : actions/checkout@v4
80+
81+ - name : Free Disk Space
82+ uses : ./.github/actions/free-disk
83+
84+ - name : Format name
85+ run : |
86+ # For branch builds (main) we want docker images tagged as 'main'. For tag pushes
87+ # use the tag name (stripped of a leading 'v').
88+ if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then
89+ echo "TAG_VERSION=main" >> $GITHUB_ENV
90+ else
91+ echo "TAG_VERSION=$(echo ${{ github.ref_name }} | tr -d v)" >> $GITHUB_ENV
92+ fi
93+
94+ # Pushes to ghcr.io/lambdaclass/rex
95+ - name : Build and push L1 Docker image
96+ id : push_l1
97+ uses : ./.github/actions/build-docker
98+ with :
99+ registry : ${{ env.REGISTRY }}
100+ username : ${{ github.actor }}
101+ password : ${{ secrets.GITHUB_TOKEN }}
102+ push : ${{ github.event_name != 'workflow_dispatch'}}
103+ tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}
104+
105+ # Creates a release on GitHub with the binaries
53106 finalize-release :
107+ if : github.ref_type == 'tag' && github.event_name != 'workflow_dispatch'
54108 needs :
55109 - build-rex
110+ - build-docker
56111 runs-on : ubuntu-latest
57112 steps :
58113 - name : Checkout Code
@@ -68,9 +123,11 @@ jobs:
68123
69124 - name : Get previous tag
70125 run : |
71- name=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | tail -2 | head -1)
72- echo "PREVIOUS_TAG: $name"
73- echo "PREVIOUS_TAG=$name" >> $GITHUB_ENV
126+ last_tag=$(git --no-pager tag --sort=creatordate | grep -v -E '^v[0-9]+\.[0-9]+\.[0-9]+-' | grep -v '${{ github.ref_name }}' | tail -1)
127+ echo "Last tag: $last_tag"
128+ common_parent=$(git merge-base ${{ github.ref_name }} $last_tag)
129+ echo "PREVIOUS_TAG: $common_parent"
130+ echo "PREVIOUS_TAG=$common_parent" >> $GITHUB_ENV
74131
75132 - name : Update CHANGELOG
76133 id : changelog
@@ -88,7 +145,10 @@ jobs:
88145 with :
89146 files : ./bin/**/*
90147 draft : false
91- prerelease : false
148+ prerelease : true
92149 tag_name : ${{ github.ref_name }}
93150 name : " rex: ${{ github.ref_name }}"
94- body : ${{ steps.changelog.outputs.changes }}
151+ body : >
152+ Installation and running instructions can be found in [our docs](https://github.com/lambdaclass/rex/blob/main/README.md).
153+
154+ ${{ steps.changelog.outputs.changes }}
0 commit comments