133 lines (114 loc) · 3.81 KB
/
cd.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
125
126
127
128
129
130
131
132
133
name: CD
on:
push:
tags:
- v*
env:
NEXT_TELEMETRY_DISABLED: 1
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 17.8.0
- name: Restore Turbo Cache
uses: actions/cache@v3
with:
path: |
**/.turbo/turbo-*.log
**/node_modules/.cache/**
key: ${{ runner.os }}-turbo-${{ hashFiles('**/yarn.lock') }}
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
with:
git_commit_gpgsign: true
git_user_signingkey: true
passphrase: ${{ secrets.FLUX_GPG_PASSPHRASE }}
gpg_private_key: ${{ secrets.FLUX_GPG_PRIVATE_KEY }}
- name: Set Canary Meta
uses: actions/github-script@v6
id: canary-meta
with:
result-encoding: json
script: |
const { version } = require('./package.json');
const isCanary = context.ref.includes('canary');
return {
version,
isCanary,
tag: isCanary ? 'canary' : 'latest',
cliffPath: isCanary ? '.github/config/canary-cliff.toml' : '.github/config/cliff.toml'
};
- name: Generate Changelog
uses: orhun/git-cliff-action@v2
with:
config: ./cliff.toml
env:
OUTPUT: CHANGELOG.md
- name: Generate Release Changelog
uses: orhun/git-cliff-action@v2
id: git-cliff
with:
config: ${{ fromJSON(steps.canary-meta.outputs.result).cliffPath }}
args: -l
env:
OUTPUT: CHANGES.md
- name: Setup NPM Auth
run: 'yarn config set -H npmAuthToken ${{ secrets.NPM_TOKEN }}'
- name: Install Dependencies
run: yarn --immutable
- name: Publish Packages
run: yarn publish --filter=\!@flux-ui/docs -- --tag ${{ fromJSON(steps.canary-meta.outputs.result).tag }}
env:
VERCEL_ARTIFACTS_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ARTIFACTS_OWNER: ${{ secrets.VERCEL_OWNER }}
- name: Add, Commit, and Push Changelog
uses: EndBug/add-and-commit@v9
with:
add: CHANGELOG.md
default_author: github_actions
message: 'chore(release): push changelog for v${{ fromJSON(steps.canary-meta.outputs.result).version }}'
- name: Set Release Body
id: release
shell: bash
run: |
r=$(cat ${{ steps.git-cliff.outputs.changelog }})
r="$(printf "$r" | tail -n +3)"
r="${r//'%'/'%25'}"
r="${r//$'\n'/'%0A'}"
r="${r//$'\r'/'%0D'}"
echo "::set-output name=release_body::$r"
- name: Release Version
uses: softprops/action-gh-release@v1
with:
body_path: ./CHANGES.md
prerelease: ${{ fromJSON(steps.canary-meta.outputs.result).isCanary }}
discussion_category_name: Releases
token: ${{ secrets.GITHUB_TOKEN }}
alert:
name: Alert
runs-on: ubuntu-latest
needs: [release]
if: always() && needs.release.result == 'failure'
steps:
- name: Get Date
id: date
run: |
echo "::set-output name=time::$(date "+%m/%d/%Y @ %H:%M")"
- name: Create Issue
uses: actions-ecosystem/action-create-issue@v1
with:
github_token: ${{ secrets.github_token }}
title: Release Error - ${{ steps.date.outputs.time }}
body: '**Error:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
assignees: Xenfo
labels: bug