-
Notifications
You must be signed in to change notification settings - Fork 3
107 lines (95 loc) · 3.38 KB
/
Copy pathrelease-artifacts.yml
File metadata and controls
107 lines (95 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Build and Upload Release Artifacts
on:
push:
tags:
- "*"
workflow_dispatch:
inputs:
tag:
description: "Git tag to build artifacts for"
required: true
permissions:
contents: write
id-token: write
attestations: write
jobs:
build-and-upload:
name: Build and Upload Release Artifacts
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
env:
OPAM_DESTDIR: ${{ github.workspace }}/opam-destdir
defaults:
run:
shell: bash
steps:
- name: Set TAG_NAME variable
run: |
if [ -n "${{ github.event.inputs.tag }}" ]; then
# workflow_dispatch case
echo "TAG_NAME=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
elif [ "${{ github.ref_type }}" = "tag" ]; then
# push tags case
echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "::error::Could not determine tag name"
exit 1
fi
- name: Wait for release to be created
env:
GH_TOKEN: ${{ github.token }}
run: |
for i in {1..30}; do
if gh release view "$TAG_NAME" --repo "$GITHUB_REPOSITORY" &>/dev/null; then
echo "Release found for tag $TAG_NAME"
exit 0
fi
echo "Waiting for release... (attempt $i/30)"
sleep 10
done
echo "::error::Release for tag $TAG_NAME was never created after 5 minutes"
exit 1
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: "${{ env.TAG_NAME }}"
- name: Setup OCaml
uses: ocaml/setup-ocaml@dec6499fef64fc5d7ed43d43a87251b7b1c306f5 # v3.4.8
with:
ocaml-compiler: "5.3.x"
opam-repositories: |
default: https://github.com/ocaml/opam-repository.git
mbarbin: https://github.com/mbarbin/opam-repository.git
# alpha: https://github.com/kit-ty-kate/opam-alpha-repository.git
# janestreet-bleeding: https://github.com/janestreet/opam-repository.git
# janestreet-bleeding-external: https://github.com/janestreet/opam-repository.git#external-packages
- name: Build Artifacts
run: |
mkdir -p "$OPAM_DESTDIR"
opam update --depexts
opam install ./volgo-vcs.opam --destdir="$OPAM_DESTDIR"
env:
OPAMYES: "true"
- name: Prepare Artifacts
run: |
os=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
arch=$(uname -m)
bin_name="${{ github.workspace }}/volgo-vcs-$TAG_NAME-$os-$arch"
cp "$OPAM_DESTDIR/bin/volgo-vcs" "$bin_name"
echo "BIN_NAME=$bin_name" >> $GITHUB_ENV
archive_name="${bin_name}.tar.gz"
tar -czf "$archive_name" -C "$OPAM_DESTDIR/bin" volgo-vcs
echo "ARCHIVE_NAME=$archive_name" >> $GITHUB_ENV
- name: Attest Build Provenance
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-path: |
${{ env.BIN_NAME }}
${{ env.ARCHIVE_NAME }}
- name: Upload Platform-Specific Binary
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "$TAG_NAME" "$ARCHIVE_NAME" --repo "$GITHUB_REPOSITORY" --clobber