Skip to content

Commit a562309

Browse files
author
Gleb
authored
Refactoring binaries workflow (#1956)
* Refactoring binaries workflow * Remove json-schema job * Move back binary attestation
1 parent 35fb32a commit a562309

2 files changed

Lines changed: 42 additions & 96 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 'Artifact upload'
2+
description: 'Uploads artifact to release'
3+
inputs:
4+
name:
5+
description: "Name of the artifact to upload"
6+
required: true
7+
path:
8+
description: "Path of the artifact to upload"
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Upload Artifact
14+
uses: actions/upload-artifact@v4
15+
with:
16+
name: ${{ inputs.name }}
17+
path: ${{ inputs.path }}
18+
19+
- name: Build provenance for attestation (release only)
20+
if: github.event_name == 'release'
21+
uses: actions/attest-build-provenance@v2
22+
with:
23+
subject-path: ${{ inputs.path }}
24+
25+
- name: Upload to Release (release only)
26+
if: github.event_name == 'release'
27+
uses: actions/github-script@v7
28+
with:
29+
script: |
30+
const fs = require('fs');
31+
await github.rest.repos.uploadReleaseAsset({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
release_id: ${{ github.event.release.id }},
35+
name: '${{ inputs.name }}',
36+
data: fs.readFileSync('${{ inputs.path }}'),
37+
});
38+
39+

.github/workflows/binaries.yml

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -57,94 +57,25 @@ jobs:
5757
- name: Build
5858
run: |
5959
cargo build --package ${{ matrix.crate.name }} --features opt --release --target ${{ matrix.sys.target }}
60-
61-
- name: Build provenance for attestation (release only)
60+
- name: Build provenance for binary attestation (release only)
6261
if: github.event_name == 'release'
6362
uses: actions/attest-build-provenance@v2
6463
with:
6564
subject-path: target/${{ matrix.sys.target }}/release/${{ matrix.crate.binary }}${{ matrix.sys.ext }}
66-
6765
- name: Compress
6866
run: |
6967
cd target/${{ matrix.sys.target }}/release
7068
tar czvf $NAME.tar.gz ${{ matrix.crate.binary }}${{ matrix.sys.ext }}
7169
7270
- name: Upload to Artifacts
73-
uses: actions/upload-artifact@v4
71+
uses: ./.github/actions/artifact-upload
7472
with:
7573
name: ${{ env.NAME }}.tar.gz
7674
path: 'target/${{ matrix.sys.target }}/release/${{ env.NAME }}.tar.gz'
7775

78-
- name: Upload to Release (release only)
79-
if: github.event_name == 'release'
80-
uses: actions/github-script@v7
81-
with:
82-
script: |
83-
const fs = require('fs');
84-
await github.rest.repos.uploadReleaseAsset({
85-
owner: context.repo.owner,
86-
repo: context.repo.repo,
87-
release_id: ${{ github.event.release.id }},
88-
name: '${{ env.NAME }}.tar.gz',
89-
data: fs.readFileSync('target/${{ matrix.sys.target }}/release/${{ env.NAME }}.tar.gz'),
90-
});
91-
92-
json-schema:
93-
needs: build
94-
runs-on: ubuntu-22.04
95-
96-
steps:
97-
- run: sudo apt-get update && sudo apt-get -y install libudev-dev libdbus-1-dev
98-
- uses: actions/checkout@v4
99-
100-
- name: Setup vars
101-
run: |
102-
version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stellar-cli") | .version')"
103-
echo "JSON_SCHEMA_NAME=stellar-xdr-${version}.json" >> $GITHUB_ENV
104-
echo "ARTIFACT_NAME=stellar-cli-${version}-x86_64-unknown-linux-gnu.tar.gz" >> $GITHUB_ENV
105-
106-
- name: Download Artifact
107-
uses: actions/download-artifact@v4
108-
with:
109-
name: ${{ env.ARTIFACT_NAME }}
110-
111-
- name: Uncompress Artifact
112-
run: tar xvf ${{ env.ARTIFACT_NAME }}
113-
114-
- name: Export JSON Schema
115-
run: |
116-
./stellar xdr types schema --type TransactionEnvelope > ${{ env.JSON_SCHEMA_NAME }}
117-
118-
- name: Upload Artifact
119-
uses: actions/upload-artifact@v4
120-
with:
121-
name: ${{ env.JSON_SCHEMA_NAME }}
122-
path: ${{ env.JSON_SCHEMA_NAME }}
123-
124-
- name: Build provenance for attestation (release only)
125-
if: github.event_name == 'release'
126-
uses: actions/attest-build-provenance@v2
127-
with:
128-
subject-path: ${{ env.JSON_SCHEMA_NAME }}
129-
130-
- name: Upload to Release (release only)
131-
if: github.event_name == 'release'
132-
uses: actions/github-script@v7
133-
with:
134-
script: |
135-
const fs = require('fs');
136-
await github.rest.repos.uploadReleaseAsset({
137-
owner: context.repo.owner,
138-
repo: context.repo.repo,
139-
release_id: ${{ github.event.release.id }},
140-
name: '${{ env.JSON_SCHEMA_NAME }}',
141-
data: fs.readFileSync('${{ env.JSON_SCHEMA_NAME }}'),
142-
});
143-
14476
installer:
14577
needs: build
14678
runs-on: windows-latest
147-
14879
steps:
14980
- uses: actions/checkout@v4
15081

@@ -161,41 +92,17 @@ jobs:
16192
uses: actions/download-artifact@v4
16293
with:
16394
name: ${{ env.ARTIFACT_NAME }}
164-
16595
- name: Uncompress Artifact
16696
run: tar xvf ${{ env.ARTIFACT_NAME }}
167-
16897
- name: Build Installer
16998
shell: powershell
17099
run: |
171100
$Env:Path += ";C:\Users\$Env:UserName\AppData\Local\Programs\Inno Setup 6"
172101
$Env:STELLAR_CLI_VERSION = "${{ env.VERSION }}"
173102
ISCC.exe installer.iss
174103
mv Output/stellar-installer.exe ${{ env.STELLAR_CLI_INSTALLER }}
175-
176104
- name: Upload Artifact
177-
uses: actions/upload-artifact@v4
105+
uses: ./.github/actions/artifact-upload
178106
with:
179107
name: ${{ env.STELLAR_CLI_INSTALLER }}
180108
path: ${{ env.STELLAR_CLI_INSTALLER }}
181-
182-
- name: Build provenance for attestation (release only)
183-
if: github.event_name == 'release'
184-
uses: actions/attest-build-provenance@v2
185-
with:
186-
subject-path: ${{ env.STELLAR_CLI_INSTALLER }}
187-
188-
- name: Upload to Release (release only)
189-
if: github.event_name == 'release'
190-
uses: actions/github-script@v7
191-
with:
192-
script: |
193-
const fs = require('fs');
194-
await github.rest.repos.uploadReleaseAsset({
195-
owner: context.repo.owner,
196-
repo: context.repo.repo,
197-
release_id: ${{ github.event.release.id }},
198-
name: '${{ env.STELLAR_CLI_INSTALLER }}',
199-
data: fs.readFileSync('${{ env.STELLAR_CLI_INSTALLER }}'),
200-
});
201-

0 commit comments

Comments
 (0)