-
Notifications
You must be signed in to change notification settings - Fork 61
64 lines (55 loc) · 2.05 KB
/
deps-release-tag.yaml
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
name: Deps Release
on:
push:
branches:
- main
permissions:
actions: write
contents: write
jobs:
tag:
name: Tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- id: tag
name: Determine tag
run: |
deps_file="./cicd/tag-deps-version.txt"
old_version="$(head -n 1 "$deps_file")"
old_ref_name="v$old_version"
new_version="$(tail -n 1 "$deps_file")"
new_ref_name="v$new_version"
create=true
if [ "$(git ls-remote origin "refs/tags/$new_ref_name" | wc -l)" = "1" ]; then
create=false
fi
echo "old-version=$old_version" | tee -a "$GITHUB_OUTPUT"
echo "old-ref-name=$old_ref_name" | tee -a "$GITHUB_OUTPUT"
echo "new-version=$new_version" | tee -a "$GITHUB_OUTPUT"
echo "new-ref-name=$new_ref_name" | tee -a "$GITHUB_OUTPUT"
echo "create=$create" | tee -a "$GITHUB_OUTPUT"
- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Tag
run: |
commit="$(git rev-parse HEAD)"
git fetch origin refs/tags/"${{ steps.tag.outputs.old-ref-name }}"
git checkout -b deps "${{ steps.tag.outputs.old-ref-name }}"
git restore --source="$commit" ./cicd ./.github/workflows/release.yaml
git add ./cicd ./.github/workflows/release.yaml
if git commit -m "bump dependency release to ${{ steps.tag.outputs.new-version }}"; then
git tag "${{ steps.tag.outputs.new-ref-name }}"
git push origin "${{ steps.tag.outputs.new-ref-name }}"
fi
- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Trigger Release
run: gh workflow run release.yaml --ref "${{ steps.tag.outputs.new-ref-name }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}