-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.8 KB
/
release.yml
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
name: Docker trigger
on:
push:
tags:
- 'v*.*.*'
jobs:
build-docker-image:
name: Build Docker Image
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.version.outputs.version }}
pr_log: ${{ steps.pr-log.outputs.pr-log }}
commit_log: ${{ steps.pr-log.outputs.commit_log }}
steps:
- uses: actions/[email protected]
- name: Build and Push Docker Image
run: |
echo "standing by mode"
- name: get the versin from package.json
id: version
run: |
version=$(jq -r ".version" package.json)
echo "version=${version}"
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Get PR titles and authors
id: pr-log
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
PREVIOUS_TAG=$(git describe --tags --always --abbrev=0 HEAD^)
PR_LOG=$(gh pr list --search "is:merged merged:>$(git log -1 --format=%aI $PREVIOUS_TAG)" --json title,author --jq '.[] | " \n - [x] " + .title + " by @" + .author.login' | tr '\n' ', ')
echo "PR_LOG<<EOF" >> $GITHUB_ENV
echo "$PR_LOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "pr-log=$PR_LOG" >> $GITHUB_OUTPUT
# extract all commit logs from the last tag
git log --pretty=format:"%s" $PREVIOUS_TAG..HEAD
# format the commit logs
git log --pretty=format:"%s" $PREVIOUS_TAG..HEAD | sed 's/^/- /g'
echo "commit_log"=$(git log --pretty=format:"%s" $PREVIOUS_TAG..HEAD | sed 's/^/- /g') >> $GITHUB_OUTPUT
create-new-release:
name: Create New Release 🎉
runs-on: ubuntu-latest
needs: [build-docker-image]
# check if there is a new tag
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Get contributors
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
CONTRIBUTORS=$(gh api repos/${{ github.repository }}/contributors --jq 'map(.login) | join(", @")')
echo "CONTRIBUTORS=@$CONTRIBUTORS" >> $GITHUB_ENV
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
gh release create v${{ needs.build-docker-image.outputs.release_version }} \
--title "v${{ needs.build-docker-image.outputs.release_version }}" \
--notes "## 🎍 What's new in this release:
${{ needs.build-docker-image.outputs.commit_log }}
## 🙏🏾 Thank You:
A big thank you to all our amazing engineers and maintainers
"