Skip to content

Commit 340ceb2

Browse files
committed
adding promote.yaml
1 parent 8d37714 commit 340ceb2

File tree

2 files changed

+112
-16
lines changed

2 files changed

+112
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,21 @@ on:
88
workflow_call:
99
inputs:
1010
is_experimental:
11-
description: "Create an experimental build (use latest constants)"
11+
description: "Create an experimental build"
1212
type: boolean
1313
default: false
1414
onnxruntime_branch:
1515
type: string
1616
default: "main"
17-
compiler_version:
18-
default: "stable"
19-
type: string
20-
constants_version:
21-
default: "stable"
22-
type: string
2317
workflow_dispatch:
2418
inputs:
2519
is_experimental:
26-
description: "Create an experimental build (use latest constants)"
20+
description: "Create an experimental build"
2721
type: boolean
2822
default: false
2923
onnxruntime_branch:
3024
type: string
3125
default: "main"
32-
compiler_version:
33-
description: "compiler_version: stable, experimental or latest (unused by ONNX Runtime)"
34-
default: "stable"
35-
type: string
36-
constants_version:
37-
description: "constants_version: stable, latest or a branch name (unused by ONNX Runtime)"
38-
default: "stable"
39-
type: string
4026
push:
4127
branches:
4228
- main

.github/workflows/promote.yaml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Promote ONNX Runtime
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
stable_promotion:
7+
required: true
8+
type: boolean
9+
10+
jobs:
11+
promote:
12+
if: inputs.stable_promotion
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
actions: read
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Get latest experimental release
22+
id: get_experimental
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
# Get the latest release (should be experimental)
27+
latest_release=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
28+
https://api.github.com/repos/${{ github.repository }}/releases \
29+
| jq -r '.[0]')
30+
31+
release_id=$(echo "$latest_release" | jq -r '.id')
32+
release_tag=$(echo "$latest_release" | jq -r '.tag_name')
33+
34+
echo "experimental_release_id=$release_id" >> $GITHUB_ENV
35+
echo "experimental_tag=$release_tag" >> $GITHUB_ENV
36+
echo "Found experimental release: $release_tag (ID: $release_id)"
37+
38+
- name: Download experimental artifacts
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
# Download all assets from the experimental release
43+
mkdir -p stable_artifacts
44+
45+
assets=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
46+
https://api.github.com/repos/${{ github.repository }}/releases/${{ env.experimental_release_id }}/assets \
47+
| jq -r '.[] | .url')
48+
49+
for asset_url in $assets; do
50+
asset_name=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$asset_url" | jq -r '.name')
51+
echo "Downloading $asset_name..."
52+
curl -L -H "Authorization: Bearer $GITHUB_TOKEN" \
53+
-H "Accept: application/octet-stream" \
54+
"$asset_url" -o "stable_artifacts/$asset_name"
55+
done
56+
57+
- name: Create stable release
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
run: |
61+
# Create stable tag and release
62+
stable_tag="stable"
63+
64+
# Delete existing stable tag/release if it exists
65+
curl -s -X DELETE \
66+
-H "Authorization: Bearer $GITHUB_TOKEN" \
67+
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$stable_tag" || true
68+
69+
# Get current commit SHA
70+
commit_sha=$(git rev-parse HEAD)
71+
72+
# Create new stable tag
73+
curl -X POST \
74+
-H "Authorization: Bearer $GITHUB_TOKEN" \
75+
-H "Accept: application/vnd.github.v3+json" \
76+
https://api.github.com/repos/${{ github.repository }}/git/refs \
77+
-d "{\"ref\": \"refs/tags/$stable_tag\", \"sha\": \"$commit_sha\"}"
78+
79+
# Create stable release
80+
release_response=$(curl -X POST \
81+
-H "Authorization: Bearer $GITHUB_TOKEN" \
82+
-H "Accept: application/vnd.github.v3+json" \
83+
https://api.github.com/repos/${{ github.repository }}/releases \
84+
-d "{
85+
\"tag_name\": \"$stable_tag\",
86+
\"name\": \"Stable Release\",
87+
\"body\": \"Stable ONNX Runtime release promoted from ${{ env.experimental_tag }}\",
88+
\"draft\": false,
89+
\"prerelease\": false
90+
}")
91+
92+
stable_release_id=$(echo "$release_response" | jq -r '.id')
93+
echo "stable_release_id=$stable_release_id" >> $GITHUB_ENV
94+
95+
- name: Upload artifacts to stable release
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
run: |
99+
for file in stable_artifacts/*; do
100+
if [ -f "$file" ]; then
101+
filename=$(basename "$file")
102+
echo "Uploading $filename to stable release..."
103+
104+
curl -X POST \
105+
-H "Authorization: Bearer $GITHUB_TOKEN" \
106+
-H "Content-Type: application/octet-stream" \
107+
--data-binary @"$file" \
108+
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.stable_release_id }}/assets?name=$filename"
109+
fi
110+
done

0 commit comments

Comments
 (0)