Skip to content

Commit 1c8a530

Browse files
committed
.github: fallback cloudsmith api secret, split job
If slug is not provided, try from secrets directly as a fallback mechanism. Split jobs to deploy in parallel. Signed-off-by: Jorge Marques <[email protected]>
1 parent aac28c6 commit 1c8a530

File tree

3 files changed

+81
-22
lines changed

3 files changed

+81
-22
lines changed

.github/workflows/build-package.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
on:
22
workflow_call:
33
outputs:
4+
asset_name:
5+
value: ${{ jobs.build.outputs.asset_name}}
6+
full_asset_name:
7+
value: ${{ jobs.build.outputs.full_asset_name}}
48
new_tag:
59
value: ${{ jobs.build.outputs.new_tag}}
610
tag:
@@ -11,6 +15,8 @@ jobs:
1115
runs-on: [self-hosted, v1]
1216

1317
outputs:
18+
asset_name: ${{ steps.get_new_tag.outputs.asset_name}}
19+
full_asset_name: ${{ steps.get_tag.outputs.full_asset_name}}
1420
new_tag: ${{ steps.get_new_tag.outputs.new_tag}}
1521
tag: ${{ steps.get_tag.outputs.tag}}
1622

@@ -71,6 +77,29 @@ jobs:
7177
pip3.13 install build
7278
python3.13 -m build
7379
80+
- name: Get full asset name
81+
run: |
82+
echo "asset_name=adi-doctools.tar.gz" >> "$GITHUB_OUTPUT"
83+
full_asset_name=$(find dist/ -maxdepth 1 -name "adi_doctools-*.tar.gz" -print -quit)
84+
echo "full_asset_name=$full_asset_name" >> "$GITHUB_OUTPUT"
85+
86+
- name: Get pre-release vars
87+
run: |
88+
source ./ci/github-api.sh
89+
release_id=$(
90+
gh-get-release-id ${{ secrets.GITHUB_TOKEN }} \
91+
${{ github.repository }} \
92+
pre-release \
93+
pre_release_id
94+
)
95+
96+
asset_id=$(
97+
gh-get-asset-id ${{ secrets.GITHUB_TOKEN }} \
98+
${{ github.repository }} \
99+
$release_id \
100+
pre_release_asset_id
101+
)
102+
74103
- name: Store the distribution packages
75104
uses: actions/upload-artifact@v4
76105
with:

.github/workflows/deploy.yml

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
on:
22
workflow_call:
33
inputs:
4+
asset_name:
5+
required: true
6+
type: string
7+
full_asset_name:
8+
required: true
9+
type: string
410
new_tag:
5-
default: false
11+
required: true
612
type: string
713
tag:
814
required: true
@@ -13,19 +19,16 @@ permissions:
1319
id-token: write
1420

1521
jobs:
16-
deploy:
22+
deploy-github:
1723
runs-on: [self-hosted, v1]
1824
permissions:
19-
id-token: write
2025
contents: write
2126

2227
steps:
2328
- name: Get assets
2429
run: |
2530
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -L -o github-api.sh \
2631
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ci/github-api.sh
27-
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -L -o cloudsmith-api.sh \
28-
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ci/cloudsmith-api.sh
2932
3033
- name: Ensure clean dist
3134
run: |
@@ -36,14 +39,6 @@ jobs:
3639
name: dist
3740
path: dist
3841

39-
- name: Get others vars
40-
run: |
41-
asset_name=adi-doctools.tar.gz
42-
echo "asset_name=$asset_name" >> "$GITHUB_ENV"
43-
44-
full_asset_name=$(find dist/ -maxdepth 1 -name "adi_doctools-*.tar.gz" -print -quit)
45-
echo "full_asset_name=$full_asset_name" >> "$GITHUB_ENV"
46-
4742
- name: Get pre-release vars
4843
run: |
4944
source ./github-api.sh
@@ -98,8 +93,8 @@ jobs:
9893
gh-upload-asset ${{ secrets.GITHUB_TOKEN }} \
9994
${{ github.repository }} \
10095
$release_id \
101-
$asset_name \
102-
$full_asset_name
96+
${{ inputs.asset_name }} \
97+
${{ inputs.full_asset_name }}
10398
10499
- name: GitHub update pre-release target commitish
105100
run: |
@@ -121,8 +116,8 @@ jobs:
121116
gh-upload-asset ${{ secrets.GITHUB_TOKEN }} \
122117
${{ github.repository }} \
123118
$pre_release_id \
124-
$asset_name \
125-
$full_asset_name
119+
${{ inputs.asset_name }} \
120+
${{ inputs.full_asset_name }}
126121
127122
- name: GitHub update latest target commitish
128123
if: ${{ inputs.new_tag == 'true' }}
@@ -146,8 +141,29 @@ jobs:
146141
gh-upload-asset ${{ secrets.GITHUB_TOKEN }} \
147142
${{ github.repository }} \
148143
$latest_id \
149-
$asset_name \
150-
$full_asset_name
144+
${{ inputs.asset_name }} \
145+
${{ inputs.full_asset_name }}
146+
147+
deploy-cloudsmith:
148+
runs-on: [self-hosted, v1]
149+
permissions:
150+
id-token: write
151+
contents: write
152+
153+
steps:
154+
- name: Get assets
155+
run: |
156+
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -L -o cloudsmith-api.sh \
157+
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ci/cloudsmith-api.sh
158+
159+
- name: Ensure clean dist
160+
run: |
161+
rm -rf dist
162+
163+
- uses: actions/download-artifact@v4
164+
with:
165+
name: dist
166+
path: dist
151167

152168
- uses: cloudsmith-io/[email protected]
153169
env:
@@ -158,6 +174,12 @@ jobs:
158174
oidc-service-slug: ${{ secrets.CLOUDSMITH_SERVICE_SLUG }}
159175
oidc-auth-only: 'true'
160176

177+
- name: Cloudsmith API Key
178+
env:
179+
CLOUDSMITH_SERVICE_SLUG: ${{ secrets.CLOUDSMITH_SERVICE_SLUG }}
180+
if: ${{ env.CLOUDSMITH_SERVICE_SLUG == '' }}
181+
run: echo "CLOUDSMITH_API_KEY=${{ secrets.CLOUDSMITH_API_KEY }}" >> "$GITHUB_ENV"
182+
161183
- name: Cloudsmith upload asset and create package
162184
if: ${{ env.CLOUDSMITH_API_KEY != '' }}
163185
run: |
@@ -174,11 +196,11 @@ jobs:
174196
tags_+=", on/${{ github.event_name }}"
175197
176198
package_file=$(
177-
cs-upload-package ${{ env.CLOUDSMITH_API_KEY }} \
199+
cs-package-upload ${{ env.CLOUDSMITH_API_KEY }} \
178200
${{ vars.CLOUDSMITH_NAMESPACE }} \
179201
${{ vars.CLOUDSMITH_REPOSITORY }} \
180-
$asset_name \
181-
$full_asset_name \
202+
${{ inputs.asset_name }} \
203+
${{ inputs.full_asset_name }}
182204
latest_package_file
183205
)
184206
@@ -188,6 +210,12 @@ jobs:
188210
$package_file \
189211
$tags_
190212
213+
deploy-gh-pages:
214+
runs-on: [self-hosted, v1]
215+
permissions:
216+
contents: write
217+
218+
steps:
191219
- uses: analogdevicesinc/doctools/blank@action
192220

193221
- name: Prepare gh-pages branch

.github/workflows/top-level.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ jobs:
3131
contents: write
3232
id-token: write
3333
with:
34+
asset_name: ${{ needs.build-package.outputs.asset_name }}
35+
full_asset_name: ${{ needs.build-package.outputs.full_asset_name }}
3436
new_tag: ${{ needs.build-package.outputs.new_tag }}
3537
tag: ${{ needs.build-package.outputs.tag }}

0 commit comments

Comments
 (0)