forked from y-scope/yscope-log-viewer
-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (100 loc) · 3.48 KB
/
release.yaml
File metadata and controls
118 lines (100 loc) · 3.48 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: "release"
on:
push:
branches: ["main"]
env:
G_RELEASE_ARTIFACT_NAME: "yscope-log-viewer-release-${{github.sha}}"
permissions: {}
concurrency:
group: "${{github.workflow}}-${{github.ref}}"
# Cancel in-progress jobs for efficiency
cancel-in-progress: true
jobs:
build:
runs-on: "ubuntu-latest"
outputs:
DIST_TAR_NAME: "${{steps.names.outputs.DIST_TAR_NAME}}"
VERSION: "${{steps.names.outputs.VERSION}}"
VERSIONED_DIST_NAME: "${{steps.names.outputs.VERSIONED_DIST_NAME}}"
steps:
- uses: "actions/checkout@v4"
with:
persist-credentials: false
submodules: "recursive"
- uses: "actions/setup-node@v4"
with:
node-version: "22"
cache: "npm"
cache-dependency-path: "./package-lock.json"
- run: "npm clean-install"
- run: "npm run build"
- name: "Determine release names"
id: "names"
run: |
PACKAGE_VERSION=$(jq -r ".version" "package.json")
BRANCH_NAME=$(echo "${GITHUB_REF}" | sed 's|refs/heads/||')
DATE=$(date --utc +'%Y%m%d')
SHORT_SHA=$(git rev-parse --short HEAD)
VERSION=${PACKAGE_VERSION}-${BRANCH_NAME}+${DATE}.${SHORT_SHA}
VERSIONED_DIST_NAME=dist-${VERSION}
echo "DIST_TAR_NAME=${VERSIONED_DIST_NAME}.tar.gz" >> "$GITHUB_OUTPUT"
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
echo "VERSIONED_DIST_NAME=${VERSIONED_DIST_NAME}" >> "$GITHUB_OUTPUT"
- name: "Generate artifacts for GH Release"
run: |
tar --create \
--gzip \
--file "${{steps.names.outputs.DIST_TAR_NAME}}" \
--transform="s|^dist|${{steps.names.outputs.VERSIONED_DIST_NAME}}|" \
dist
- uses: "actions/upload-artifact@v4"
with:
name: "${{env.G_RELEASE_ARTIFACT_NAME}}"
path: "${{steps.names.outputs.DIST_TAR_NAME}}"
if-no-files-found: "error"
retention-days: 1
- name: "Upload static files as GH Pages artifact"
uses: "actions/upload-pages-artifact@v3"
with:
path: "./dist"
release:
needs: "build"
runs-on: "ubuntu-latest"
permissions:
# To create a release
contents: "write"
steps:
- uses: "actions/checkout@v4"
with:
persist-credentials: false
submodules: "recursive"
- uses: "actions/download-artifact@v4"
with:
name: "${{env.G_RELEASE_ARTIFACT_NAME}}"
- name: "Create GitHub pre-release"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
gh release create "v${{needs.build.outputs.VERSION}}" \
"${{needs.build.outputs.DIST_TAR_NAME}}" \
--fail-on-no-commits \
--prerelease \
--title "v${{needs.build.outputs.VERSION}}" \
--notes "This is a pre-release and is not recommended for production. Click \
[here](https://github.com/y-scope/yscope-log-viewer/releases?q=prerelease%3Afalse) to \
view all production releases."
deploy:
needs: "release"
permissions:
# To deploy to Pages
pages: "write"
# To request a JWT from GitHub for certifying the origin of the deployment
id-token: "write"
runs-on: "ubuntu-latest"
environment:
name: "github-pages"
url: "${{steps.deployment.outputs.page_url}}"
steps:
- name: "Deploy to GitHub Pages"
id: "deployment"
uses: "actions/deploy-pages@v4"