Skip to content

Commit 8e31e33

Browse files
Release pr job + tester
1 parent 890dd56 commit 8e31e33

3 files changed

Lines changed: 104 additions & 0 deletions

File tree

.github/workflows/release-pr.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Release version"
8+
required: true
9+
default: 0.0.0
10+
type: string
11+
12+
workflow_call:
13+
inputs:
14+
version:
15+
default: 0.0.0
16+
type: string
17+
push:
18+
branch: [main]
19+
20+
jobs:
21+
release-pr:
22+
runs-on: "macos-latest"
23+
strategy:
24+
matrix:
25+
node-version: [16.x]
26+
steps:
27+
- uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Check Version
32+
run: bash -c '$([[ "${{ inputs.version }}" =~ ^([0-9]+\.){2}[0-9]+ ]])'
33+
34+
- run: |
35+
git config --global user.name "github"
36+
git config --global user.email "noreply@github.com"
37+
38+
- name: Use Node.js ${{ matrix.node-version }}
39+
uses: actions/setup-node@v3
40+
with:
41+
node-version: ${{ matrix.node-version }}
42+
cache: "yarn"
43+
44+
- run: yarn install --immutable
45+
46+
- name: Changelog
47+
id: create-changelog
48+
run: |
49+
TMPFILE=/tmp/tmpfile
50+
bash scripts/generate_changelog.sh $TMPFILE
51+
cat $TMPFILE >> $GITHUB_STEP_SUMMARY
52+
cat $TMPFILE >> CHANGELOG.md
53+
echo "changelog_file=$TMPFILE" >> $GITHUB_OUTPUT
54+
55+
- name: Bump version
56+
run: yarn workspaces foreach version ${{ inputs.version }}
57+
if: ${{ inputs.version }} != "0.0.0"
58+
59+
- name: Create Branch
60+
id: create-branch
61+
run: |
62+
COMMIT_SHA=$(git rev-parse --short HEAD)
63+
BRANCH=releases/draft-$COMMIT_SHA-$(date +%s)
64+
git checkout -b $BRANCH
65+
git add CHANGELOG.md **/package.json
66+
git status
67+
git commit -m "Changelog & version bump to ${{ inputs.version }}"
68+
git push origin HEAD
69+
echo "branch_name=$BRANCH" >> $GITHUB_OUTPUT
70+
if: ${{ inputs.version }} != "0.0.0"
71+
72+
- name: Create PR
73+
run: |
74+
gh pr create -B main -H ${{ steps.create-branch.outputs.branch_name }} --title "Release: v${{ inputs.version }}" --body-file ${{ steps.create-changelog.outputs.changelog_file }}
75+
rm ${{ steps.create-changelog.outputs.changelog_file }}
76+
env:
77+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
if: ${{ inputs.version }} != "0.0.0"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: TestRelease PR
2+
3+
on:
4+
pull_request:
5+
branch: [main]
6+
push:
7+
branch: [main]
8+
9+
jobs:
10+
test-release-pr:
11+
name: Test Release PR
12+
uses: ./.github/workflows/release-pr.yml
13+
with:
14+
version: 0.0.1

scripts/generate_changelog.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
for PACKAGE in "packages/databricks-vscode" "packages/databricks-sdk" "packages/databricks-vscode-types" "."; do
2+
echo "## $PACKAGE" >> $1
3+
4+
TAG=$(git describe --abbrev=0 --match "release-v*")
5+
if [ $? -ne 0 ]; then
6+
echo "No release tag matching pattern 'release-v*' found. Generating changelog from beggining"
7+
yarn conventional-changelog -k $PACKAGE --commit-path $PACKAGE >> $1
8+
else
9+
echo "Release tag found. Generating changelog from $TAG"
10+
yarn conventional-changelog --tag-prefix="release-v" -k $PACKAGE --commit-path $PACKAGE >> $1
11+
fi
12+
done

0 commit comments

Comments
 (0)