-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (50 loc) · 1.99 KB
/
Copy pathrelease.yml
File metadata and controls
50 lines (50 loc) · 1.99 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
name: Release
on:
push:
branches: [main]
paths: ['packages/*/package.json']
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
if: github.ref == 'refs/heads/main'
permissions:
contents: write
actions: write
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- name: Release merged package versions
env:
BEFORE: ${{ github.event.before }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
for package in context-tree git-stats; do
version=$(jq -r .version "packages/$package/package.json")
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]
if [ "$GITHUB_EVENT_NAME" = push ]; then
previous=$(git show "$BEFORE:packages/$package/package.json" | jq -r .version)
if [ "$previous" = "$version" ]; then continue; fi
fi
tag="$package-v$version"
if git show-ref --verify --quiet "refs/tags/$tag"; then
test "$(git rev-parse "refs/tags/$tag^{commit}")" = "$GITHUB_SHA" || { echo 'Existing tag targets a different commit' >&2; exit 1; }
fi
gh api "repos/$GITHUB_REPOSITORY/releases?per_page=100" --jq '.[].tag_name' > releases.txt
if ! grep -Fxq "$tag" releases.txt; then
grep -Fq "## $version" "packages/$package/CHANGELOG.md"
flags=(); case "$version" in *-*) flags=(--prerelease);; esac
gh release create "$tag" --target "$GITHUB_SHA" --title "$tag" --generate-notes "${flags[@]}"
gh workflow run publish.yml --ref "$tag" -f package="$package"
elif [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then
gh workflow run publish.yml --ref "$tag" -f package="$package"
fi
done