-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (86 loc) · 3.64 KB
/
Copy pathtrigger-release.yml
File metadata and controls
90 lines (86 loc) · 3.64 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
name: Trigger Release
# Release flow:
# - Run *this* workflow from the internal repository.
# - This will create and push a version bump commit and tag it.
# - ci.yml's sync job will trigger and sync both the commit and tag to the external repository.
# - The tag push will trigger the external repository's release job.
on:
workflow_dispatch:
permissions:
contents: read
jobs:
tag-new-release:
if: github.repository_owner != 'arm'
runs-on: ubuntu-latest
steps:
# We want our tag push at the end to trigger a workflow. We can't do that using repository's GITHUB_TOKEN.
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow#triggering-a-workflow-from-a-workflow
- uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc # v3.0.0
id: get_app_token
with:
app_id: ${{ secrets.ML_REPO_ACCESS_APP_ID }}
private_key: ${{ secrets.ML_REPO_ACCESS_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
token: ${{ steps.get_app_token.outputs.token }}
persist-credentials: false
- name: Set git config for ML Repo bot
run: |
git config --global user.email "1736931+model-explorer-plugins-repo-access[bot]@users.noreply.github.com"
git config --global user.name "model-explorer-plugins-repo-access[bot]"
- name: Calculate new version
uses: orhun/git-cliff-action@d77b37db2e3f7398432d34b72a12aa3e2ba87e51 # v4.6.0
id: git-cliff
with:
config: cliff.toml
args: --bump --no-exec --github-repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if there's anything to release
env:
BUMPED_TAG: ${{ steps.git-cliff.outputs.version }}
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'v0.0.0')
if [[ "$BUMPED_TAG" == "null" || -z "$BUMPED_TAG" ]]; then
exit 1
fi
if [[ "$BUMPED_TAG" == "$LATEST_TAG" ]]; then
echo "Bumped tag is the same as latest: $BUMPED_TAG. Nothing to release."
exit 1
fi
- name: Trim the v from version tag
id: strip-v-from-version-tag
env:
RELEASE_VERSION: ${{ steps.git-cliff.outputs.version }}
run: |
RELEASE_VERSION_WITHOUT_V="${RELEASE_VERSION#v}"
echo "version=$RELEASE_VERSION_WITHOUT_V" >> "$GITHUB_OUTPUT"
- name: Update pyproject version
env:
VERSION: ${{ steps.strip-v-from-version-tag.outputs.version }}
run: |
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
git add pyproject.toml
git commit -m "Update pyproject version to v$VERSION"
git push
- name: Tag new release
env:
VERSION: ${{ steps.git-cliff.outputs.version }}
run: |
git tag "$VERSION"
git push origin tag "$VERSION"
- name: Update umbrella submodule pointer
env:
GH_TOKEN: ${{ steps.get_app_token.outputs.token }}
INTERNAL_REPOSITORY: ${{ secrets.INTERNAL_REPOSITORY }}
REPOSITORY_NAME: ${{ github.event.repository.name }}
VERSION: ${{ steps.git-cliff.outputs.version }}
run: |
gh api \
--method POST \
"/repos/$INTERNAL_REPOSITORY/dispatches" \
-f event_type=update-submodule \
-f client_payload[name]="$REPOSITORY_NAME" \
-f client_payload[tag]="$VERSION"