-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (80 loc) · 2.94 KB
/
release-package.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
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
name: Release Package
on:
workflow_dispatch:
inputs:
package:
type: choice
description: package
options:
- barcode
- channable
- clockify-enhanced
- cronhooks
- fulfillmenttools
- google-enhanced
- kaufland-marketplace
- moco
- otto-market
- sentry-io-enhanced
permissions:
contents: write
pull-requests: write
env:
NODE_VERSION: 20.13.1
jobs:
release-package:
name: Release Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
filter: 'blob:none'
fetch-depth: 0
fetch-tags: true
- name: Check on existing release branch
# yamllint disable rule:line-length
run: |
if git ls-remote --heads origin | grep "refs/heads/release-${{ github.event.inputs.package }}@*"; then
echo "::error ::Release branch already exists for package: \"${{ github.event.inputs.package }}\" please remove or merge branch before executing again."
exit 1
fi
# yamllint enable rule:line-length
- name: Configure git User
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Retrieve short commit hash
id: short_commit_hash
run: echo "short_commit_hash=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Switch to release branch
# yamllint disable-line rule:line-length
run: git switch --force-create release-${{ github.event.inputs.package }}@${{ steps.short_commit_hash.outputs.short_commit_hash }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Bump version and create changelog
run: |
npx nx release \
--projects=${{ github.event.inputs.package }} \
--skip-publish
- name: Push changes
# yamllint disable-line rule:line-length
run: git push origin release-${{ github.event.inputs.package }}@${{ steps.short_commit_hash.outputs.short_commit_hash }}
- name: Create pull request
# yamllint disable rule:line-length
run: |
gh pr create \
--base main \
--body "This is an automated pull request to create a new release of the package ${{ github.event.inputs.package }}." \
--head release-${{ github.event.inputs.package }}@${{ steps.short_commit_hash.outputs.short_commit_hash }} \
--label release \
--reviewer ${{ github.actor }} \
--title "Release ${{ github.event.inputs.package }}"
# yamllint enable rule:line-length
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}