-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (108 loc) · 4.33 KB
/
release.yml
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Auto Test/Bump/Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Auto Test/Bump/Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- name: Checkout ${{ github.ref_name }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Caching Toolchain
uses: actions/cache@v4
id: cache-sdk-repo
with:
path: |
~/.asdf/
~/.local/share/pnpm/store/
key: asdf-store-${{ runner.os }}
- name: Install Toolchain
uses: asdf-vm/actions/install@v3
with:
skip_install: ${{ steps.cache-sdk-repo.outputs.cache-hit == 'true' }}
- name: Prepare Project
run: |
chmod a+x .changeset/*.sh
echo "install pnpm-hoist-layer to devDep"
pnpm -w i --no-frozen-lockfile --ignore-pnpmfile
echo "reset the ci lockfile"
git restore pnpm-lock.yaml
echo "install all deps by lockfile"
pnpm i --frozen-lockfile
# https://github.com/changesets/action
cat > "$HOME/.npmrc" << EOF
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
echo "## Project Version" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Name | Version |" >> $GITHUB_STEP_SUMMARY
echo "|------|---------|" >> $GITHUB_STEP_SUMMARY
echo "| $(jq -r '.name' package.json) | $(jq -r '.version' package.json) |" >> $GITHUB_STEP_SUMMARY
echo "| node | $(node -v) |" >> $GITHUB_STEP_SUMMARY
echo "| pnpm | $(pnpm -v) |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Test and Coverage
run: |
pnpm dev:test
- name: Common Coverage
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: './layers/common'
- name: Mobile Coverage
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: './layers/mobile'
- name: Changeset Auto
id: changesets
uses: changesets/action@v1
with:
commit: ":bookmark: bumping versions"
title: ":rocket: release versions"
version: .changeset/version-top.sh
publish: .changeset/publish-all.sh
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Changeset Status
if: steps.changesets.outputs.published == 'true' || steps.changesets.outputs.hasChangesets == 'true'
run: |
echo "## Changeset Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Status | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Published | ${{ steps.changesets.outputs.published }} |" >> $GITHUB_STEP_SUMMARY
echo "| Changeset | ${{ steps.changesets.outputs.hasChangesets }} |" >> $GITHUB_STEP_SUMMARY
echo "| PR Number | ${{ steps.changesets.outputs.pullRequestNumber }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: Github Release
id: release
if: steps.changesets.outputs.published == 'true'
uses: halvardssm/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: "./package.json"
- name: Publish Status
if: steps.changesets.outputs.published == 'true'
run: |
echo "## Publish Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Package | Version |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|---------|" >> $GITHUB_STEP_SUMMARY
echo "| $(jq -r '.name' package.json) | $(jq -r '.version' package.json) |" >> $GITHUB_STEP_SUMMARY
# Format published packages
publishedPackages='${{ steps.changesets.outputs.publishedPackages }}'
echo "$publishedPackages" | jq -c '.[]' | while read pkg; do
echo "| $(echo $pkg | jq -r '.name') | $(echo $pkg | jq -r '.version') |" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY