Skip to content

Commit 845194b

Browse files
authored
Merge pull request #21 from Sensirion/update_workflows
Update driver workflows
2 parents ac46ae8 + a8aa166 commit 845194b

File tree

4 files changed

+62
-36
lines changed

4 files changed

+62
-36
lines changed

.github/workflows/driver.common.github_release.yml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,9 @@ jobs:
3131
'${{ github.ref_name }}' metadata.yml
3232
--repo '${{ github.repository }}'
3333
create-driver-index-release:
34-
runs-on: ubuntu-latest
35-
needs: create-github-release
36-
steps:
37-
- name: Driver Index login
38-
run: |
39-
echo "DI_KNOX_TOKEN=$(curl -s --request POST \
40-
--url "${{ vars.DI_BASE_URL }}/auth/login/" \
41-
-H "Authorization: Basic ${{ secrets.DI_BASIC_AUTH_TOKEN }}" | jq '.token' -r)" >> $GITHUB_ENV
42-
- name: Get ID of driver entry in DI
43-
env:
44-
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
45-
run: |
46-
DI_DRIVER_ID=$(curl -s --url "${{ vars.DI_BASE_URL }}/drivers/" \
47-
-H "Authorization: Token $DI_KNOX_TOKEN" \
48-
| jq ".[] | select(.repository_link == \"$REPO_URL\") | .id")
49-
50-
if [[ $DI_DRIVER_ID == '' ]]; then
51-
echo "::error::Driver not found" && exit 1
52-
else
53-
echo "Driver found with ID $DI_DRIVER_ID"
54-
echo "DI_DRIVER_ID=$DI_DRIVER_ID" >> $GITHUB_ENV
55-
fi
56-
- name: Add release to Driver Index
57-
env:
58-
GH_TOKEN: ${{ github.token }}
59-
run: |
60-
gh release view --repo "${GITHUB_REPOSITORY}" --json tagName,publishedAt,zipballUrl \
61-
| jq -c --arg driver "$DI_DRIVER_ID" '{release_date: .publishedAt, version: .tagName, download_link: .zipballUrl, driver: $driver}' \
62-
| curl --fail --url "${{ vars.DI_BASE_URL }}/driver_releases/" --request POST \
63-
-H "Authorization: Token $DI_KNOX_TOKEN" \
64-
-H "Content-Type: application/json" \
65-
--data-binary @-
66-
- name: Driver Index logout
67-
if: always()
68-
run: |
69-
curl --request POST --url "${{ vars.DI_BASE_URL }}/auth/logout/" -H "Authorization: Token $DI_KNOX_TOKEN"
34+
needs: create-github-release
35+
uses: sensirion/.github/.github/workflows/driver_index.common.create_release.yml
36+
secrets:
37+
DI_BASIC_AUTH_TOKEN: ${{ secrets.DI_BASIC_AUTH_TOKEN }}
38+
with:
39+
DI_BASE_URL: ${{ vars.DI_BASE_URL }}

.github/workflows/driver.generated.metadata_check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
# checkout last real commit, not the generated pull request commit
2020
# variable is empty in case it runs on push, thus normal branch checkout will happen
2121
ref: ${{ github.event.pull_request.head.sha }}
22+
fetch-depth: 0 # fetch all history for accurate git log
2223
- name: Check metadata exitst
2324
run: |
2425
if ! [ -f "metadata.yml" ]; then

.github/workflows/driver.python.pypi_publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,10 @@ jobs:
9999
# upload sigstore-produced signatures and certificates from dist
100100
run: |
101101
gh release upload '${{ github.ref_name }}' dist/*.sigstore.json --repo '${{ github.repository }}'
102+
create-driver-index-release:
103+
needs: github-release
104+
uses: sensirion/.github/.github/workflows/driver_index.common.create_release.yml
105+
secrets:
106+
DI_BASIC_AUTH_TOKEN: ${{ secrets.DI_BASIC_AUTH_TOKEN }}
107+
with:
108+
DI_BASE_URL: ${{ vars.DI_BASE_URL }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Create Driver Index Release
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
DI_BASIC_AUTH_TOKEN:
7+
required: true
8+
inputs:
9+
DI_BASE_URL:
10+
required: true
11+
type: string
12+
jobs:
13+
create-driver-index-release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Driver Index login
17+
run: |
18+
echo "DI_KNOX_TOKEN=$(curl -s --request POST \
19+
--url \"${{ inputs.DI_BASE_URL }}/auth/login/\" \
20+
-H \"Authorization: Basic ${{ secrets.DI_BASIC_AUTH_TOKEN }}\" | jq '.token' -r)" >> $GITHUB_ENV
21+
- name: Get ID of driver entry in DI
22+
env:
23+
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
24+
run: |
25+
DI_DRIVER_ID=$(curl -s --url \"${{ inputs.DI_BASE_URL }}/drivers/\" \
26+
-H \"Authorization: Token $DI_KNOX_TOKEN\" \
27+
| jq ".[] | select(.repository_link == \"$REPO_URL\") | .id")
28+
29+
if [[ $DI_DRIVER_ID == '' ]]; then
30+
echo "::error::Driver not found" && exit 1
31+
else
32+
echo "Driver found with ID $DI_DRIVER_ID"
33+
echo "DI_DRIVER_ID=$DI_DRIVER_ID" >> $GITHUB_ENV
34+
fi
35+
- name: Add release to Driver Index
36+
env:
37+
GH_TOKEN: ${{ github.token }}
38+
run: |
39+
gh release view --repo "${GITHUB_REPOSITORY}" --json tagName,publishedAt,zipballUrl \
40+
| jq -c --arg driver "$DI_DRIVER_ID" '{release_date: .publishedAt, version: .tagName, download_link: .zipballUrl, driver: $driver}' \
41+
| curl --fail --url "${{ inputs.DI_BASE_URL }}/driver_releases/" --request POST \
42+
-H "Authorization: Token $DI_KNOX_TOKEN" \
43+
-H "Content-Type: application/json" \
44+
--data-binary @-
45+
- name: Driver Index logout
46+
if: always()
47+
run: |
48+
curl --request POST --url "${{ inputs.DI_BASE_URL }}/auth/logout/" -H "Authorization: Token $DI_KNOX_TOKEN"

0 commit comments

Comments
 (0)