-
Notifications
You must be signed in to change notification settings - Fork 1.7k
102 lines (98 loc) · 3.02 KB
/
auto_release_internal.yml
File metadata and controls
102 lines (98 loc) · 3.02 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
name: Auto-release internal packages
on:
push:
branches: [main]
paths:
- "packages/reflex-components-internal/**"
- "packages/reflex-site-shared/**"
- ".github/workflows/auto_release_internal.yml"
workflow_dispatch:
inputs:
package:
description: "Package to release"
required: true
type: choice
options:
- reflex-components-internal
- reflex-site-shared
permissions:
contents: write
actions: write
jobs:
detect:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.detect.outputs.packages }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- id: detect
env:
EVENT_NAME: ${{ github.event_name }}
DISPATCH_PACKAGE: ${{ inputs.package }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
printf 'packages=["%s"]\n' "$DISPATCH_PACKAGE" >> "$GITHUB_OUTPUT"
exit 0
fi
PACKAGES=()
for pkg in reflex-components-internal reflex-site-shared; do
if git diff --name-only HEAD~1 HEAD -- "packages/$pkg/" | grep -q .; then
PACKAGES+=("\"$pkg\"")
fi
done
JOINED=$(IFS=,; echo "${PACKAGES[*]:-}")
echo "packages=[$JOINED]" >> "$GITHUB_OUTPUT"
release:
needs: detect
if: needs.detect.outputs.packages != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{ fromJson(needs.detect.outputs.packages) }}
fail-fast: false
concurrency:
group: release-${{ matrix.package }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v6
with:
fetch-tags: true
fetch-depth: 0
- name: Compute next version
id: version
env:
PKG: ${{ matrix.package }}
run: |
set -euo pipefail
LATEST=$(git tag -l "${PKG}-v*" | sed "s/^${PKG}-v//" | sort -V | tail -1)
if [ -z "$LATEST" ]; then
NEXT="0.0.1"
else
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST"
NEXT="${MAJOR}.${MINOR}.$((PATCH + 1))"
fi
echo "version=$NEXT" >> "$GITHUB_OUTPUT"
echo "tag=${PKG}-v${NEXT}" >> "$GITHUB_OUTPUT"
- name: Create GitHub release (not marked latest)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
PKG: ${{ matrix.package }}
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
gh release create "$TAG" \
--title "$PKG@$VERSION" \
--notes "Automated release for $PKG v$VERSION" \
--target "$GITHUB_SHA" \
--latest=false
- name: Trigger publish workflow
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
gh workflow run publish.yml -f tag="$TAG"