-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (60 loc) · 2.01 KB
/
release.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
65
66
67
68
69
name: Release
on:
push:
branches:
- main
- dev
#on:
# workflow_call:
# inputs:
# tag:
# required: true
# type: string
jobs:
build:
uses: ./.github/workflows/compile.yaml
release:
runs-on: ubuntu-22.04
needs: build
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
steps:
- name: Compose Release Tag
id: release_tag
run: |
if [[ ${{ github.event_name }} == "pull_request" ]]; then
SHA=${{ github.event.pull_request.head.sha }}
else
SHA=$(echo "$GITHUB_CONTEXT" | jq '.event.commits[].id' | tail -2 | head -1 | sed 's/\"//g')
fi
DATE=$(git show -s --format=%ad --date=format:'%Y-%m-%d' $SHA)
TAG=dev-$DATE-${SHA::8}
echo "SHA: $SHA"
echo "TAG: $TAG"
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "SHA=$SHA" >> $GITHUB_OUTPUT
# - name: login
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
- name: Test release
id: test_release
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checokut -b dev-nightly
git add .
git commit -m "generated"
git push origin dev-nightly
- name: Release
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO=$(echo "$GITHUB_CONTEXT" | jq -r '.repository')
TAG=${{ steps.release_tag.outputs.TAG }}
SHA=${{ steps.release_tag.outputs.SHA }}
# git tag -a ${{ steps.release_tag.outputs.TAG }}
# git push --follow-tags
gh api repos/$REPO/git/refs -f ref="refs/tags/$TAG" -f sha="$SHA"
# gh release create ${{ steps.release_tag.outputs.TAG }} --repo "$REPO" --title "some title" --generate-notes