Repository navigation
74 lines (65 loc) · 2.42 KB
/
Copy pathrelease_code.yaml
File metadata and controls
74 lines (65 loc) · 2.42 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
name: Release - Code & Repository
run-name: Release - Code & Repository (${{ github.ref_name }})
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
force:
required: false
type: boolean
default: false
description: Force replace an existing tag
workflow_call:
inputs:
skip_approval:
required: false
type: boolean
default: false
jobs:
approve:
if: ${{ !inputs.skip_approval }}
name: Approve Release
runs-on: ubuntu-latest
timeout-minutes: 30
environment: release
steps:
- run: echo "Release approved"
release_code_repo:
name: Release Code
needs: [approve]
if: ${{ !cancelled() && (needs.approve.result == 'success' || needs.approve.result == 'skipped') }}
runs-on: aihub-models-ubuntu-2404-ec2
steps:
- name: Verify running on a tag
run: |
if [[ "${{ github.ref }}" != refs/tags/* ]]; then
echo "Error: This workflow must be run from a tag, got ${{ github.ref }}"
exit 1
fi
- uses: actions/checkout@v7
with:
# Prevent checkout from configuring its own credential helper,
# which would override PROD_GH_TOKEN with GITHUB_TOKEN.
persist-credentials: false
# Fetch full history so pushing the tag sends every object it
# references to the public repo. A shallow checkout (the default)
# only has the tag commit, causing "did not receive expected
# object" / "remote unpack failed" on push.
fetch-depth: 0
- name: Push tag to public repository
env:
QAIHM_TAG: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.PROD_GH_TOKEN }}
run: |
git config --local credential.helper '!f() { echo "username=x-access-token"; echo "password=$GH_TOKEN"; }; f'
git remote add public https://github.com/qualcomm/ai-hub-models.git
FORCE_FLAG=""
if [ "${{ inputs.force }}" == "true" ]; then
FORCE_FLAG="-f"
else
if git ls-remote --tags public | grep -q "refs/tags/$QAIHM_TAG$"; then
echo "Tag $QAIHM_TAG already exists in the public repository. Aborting release. Use force to replace."
exit 1
fi
fi
git push $FORCE_FLAG public "$QAIHM_TAG"