-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathreusable-create-github-release.yml
More file actions
92 lines (82 loc) · 2.9 KB
/
Copy pathreusable-create-github-release.yml
File metadata and controls
92 lines (82 loc) · 2.9 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
name: Create GitHub Release
on:
workflow_call:
inputs:
app:
description: "The app to release" # dir name in ./apps/*
required: true
type: string
sha:
description: "The commit SHA to release (defaults to GITHUB_SHA)"
required: false
type: string
outputs:
git_tag:
description: "The git tag released"
value: ${{ jobs.release.outputs.git_tag }}
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
outputs:
git_tag: ${{ steps.bumps.outputs.git_tag }}
steps:
- name: Full history checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup Nodejs
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: "package.json"
- name: Restore Dependencies Cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: deps-cache
with:
path: |
node_modules
packages/releaser/node_modules
key: deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install Dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
npm run safe-install -- -w packages/releaser
- name: Get Version and Changelog Updates
id: bumps
env:
APP_NAME: ${{ inputs.app }}
APP_ALIASES: >-
{
"deploy-web": "console-web",
"api": "console-api"
}
RELEASE_FROM_SHA: ${{ inputs.sha || github.sha }}
run: |
app_alias=$(echo "$APP_ALIASES" | jq -r --arg app "$APP_NAME" '.[$app] // $app')
commits_analysis=$(node ./packages/releaser/recommended-bump.js \
--tag-prefix="$app_alias/v" \
--path "apps/$APP_NAME" \
--repo-url "https://github.com/$GITHUB_REPOSITORY" \
--target-sha "$RELEASE_FROM_SHA")
echo "$commits_analysis" | jq
next_tag=$(echo "$commits_analysis" | jq -r '.nextTag // empty')
changelog=$(echo "$commits_analysis" | jq -r '.changelog // empty')
echo "git_tag=$next_tag" >> "$GITHUB_OUTPUT"
{
echo "changelog<<CHANGELOG_EOF"
echo "$changelog"
echo "CHANGELOG_EOF"
} >> "$GITHUB_OUTPUT"
- name: Create Release
if: ${{ steps.bumps.outputs.git_tag != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_CHANGELOG: ${{ steps.bumps.outputs.changelog }}
RELEASE_VERSION: ${{ steps.bumps.outputs.git_tag }}
run: |
gh release create "$RELEASE_VERSION" \
--repo "$GITHUB_REPOSITORY" \
--title "$RELEASE_VERSION" \
--notes "$RELEASE_CHANGELOG"