-
Notifications
You must be signed in to change notification settings - Fork 4
128 lines (114 loc) · 4.06 KB
/
create_release.yml
File metadata and controls
128 lines (114 loc) · 4.06 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Create Release and Update Documentation
on:
push:
branches:
- main
paths:
- 'package.json'
workflow_dispatch:
inputs:
version:
description: 'Version to release (leave empty to use package.json version)'
required: false
type: string
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from package.json
id: get_version
run: |
if [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
else
VERSION=$(jq -r '.version' package.json)
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Git Tag
run: |
VERSION="${{ steps.get_version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
echo "Tag v${VERSION} already exists"
else
git tag -a "v${VERSION}" -m "Release v${VERSION}"
git push origin "v${VERSION}"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Release v${{ steps.get_version.outputs.version }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-documentation:
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: read
env:
AGENT_NAME: "unity"
AGENT_TITLE: "Unity agent"
DOCS_PATH: "src/content/docs/release-notes/mobile-release-notes/unity-release-notes"
REPO_URL: "https://github.com/newrelic/newrelic-unity-agent"
BOT_EMAIL: ${{ secrets.BOT_EMAIL }}
steps:
- name: Checkout Agent Repo
uses: actions/checkout@v4
with:
path: agent-repo
- name: Checkout Docs-Website
uses: actions/checkout@v4
with:
repository: newrelic/docs-website
ref: develop
token: ${{ secrets.BOT_PAT }}
path: docs-website
- name: Generate Release Document
working-directory: agent-repo
env:
PASSED_VERSION: ${{ needs.create-release.outputs.version }}
GH_TOKEN: ${{ secrets.BOT_PAT }}
run: |
chmod +x ./.github/scripts/generate-docs.sh
./.github/scripts/generate-docs.sh
if [ -f "release_info.env" ]; then
cat release_info.env >> $GITHUB_ENV
else
echo "::error::Script failed to create release_info.env"
exit 1
fi
- name: Create branch, commit, and PR
env:
GH_TOKEN: ${{ secrets.BOT_PAT }}
run: |
cd docs-website
VERSION="${{ env.FINAL_VERSION }}"
VERSION_STRIPPED=$(echo "${VERSION}" | tr -d '.')
FINAL_FILENAME="${{ env.AGENT_NAME }}-agent-${VERSION_STRIPPED}.mdx"
BRANCH_NAME="${{ env.AGENT_NAME }}_release_notes_$(echo ${VERSION} | tr '.' '-')"
git config user.name "newrelic-mobile-agent-bot"
git config user.email "${{ env.BOT_EMAIL }}"
git checkout -b "$BRANCH_NAME"
cp ../agent-repo/release-notes.mdx "${{ env.DOCS_PATH }}/$FINAL_FILENAME"
git add .
git commit -m "chore(${{ env.AGENT_NAME }} agent): add release notes v${VERSION}"
git push origin "$BRANCH_NAME"
gh pr create \
--repo newrelic/docs-website \
--base develop \
--head "$BRANCH_NAME" \
--title "${{ env.AGENT_TITLE }} Release Notes v${VERSION}" \
--body "Automated PR for ${{ env.AGENT_TITLE }} v${VERSION} release." \
--label "documentation"