-
Notifications
You must be signed in to change notification settings - Fork 784
84 lines (82 loc) · 3.02 KB
/
release_interpret.yml
File metadata and controls
84 lines (82 loc) · 3.02 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
name: release_interpret
on:
release:
types:
- published
workflow_dispatch:
inputs:
commit_id:
description: 'Commit ID (required for manual trigger)'
required: true
jobs:
publish_packages:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions/setup-node@v4
with:
node-version: '*'
registry-url: 'https://registry.npmjs.org'
- name: Find CI workflow run by commit ID
id: find_workflow
run: |
if [ "${{ github.event_name }}" == "release" ]; then
commit_id="${{ github.event.release.target_commitish }}"
else
commit_id="${{ github.event.inputs.commit_id }}"
fi
if [ -z "$commit_id" ]; then
echo "Error: commit_id is empty."
exit 1
fi
if git show-ref --verify --quiet refs/heads/${commit_id}; then
# If it's a valid branch, resolve it to a commit ID
commit_id=$(git rev-parse ${commit_id})
fi
echo "Commit ID: ${commit_id}"
workflow_runs=$(gh api -X GET "/repos/${{ github.repository }}/actions/runs?status=success" -q '.workflow_runs | map(select(.head_commit.id == "'"${commit_id}"'" and .name == "interpret-CI")) | sort_by(.created_at) | reverse | .[0]')
run_id=$(echo "$workflow_runs" | jq -r '.id')
if [[ -z "$run_id" || "$run_id" == "null" ]]; then
echo "No successful run found – looking for the last failed run."
workflow_runs=$(gh api -X GET "/repos/${{ github.repository }}/actions/runs" -q '.workflow_runs | map(select(.head_commit.id == "'"${commit_id}"'" and .name == "interpret-CI")) | sort_by(.created_at) | reverse | .[0]')
run_id=$(echo "$workflow_runs" | jq -r '.id')
fi
echo "Run ID: ${run_id}"
echo "run_id=${run_id}" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download npm artifact
uses: actions/download-artifact@v4
with:
run-id: ${{ env.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
name: npm
path: bld/npm
- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
run-id: ${{ env.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
name: sdist
path: dist
- name: Download bdist artifact
uses: actions/download-artifact@v4
with:
run-id: ${{ env.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
name: bdist
path: dist
- name: Publish NPM
run: |
cd bld/npm
npm publish interpretml-interpret-inline-*.tgz
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1