-
Notifications
You must be signed in to change notification settings - Fork 31
142 lines (120 loc) · 5.23 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Publiser nye versjoner
on:
push:
branches:
- main
run-name: Publiser endrede pakker. Siste commit er ${{ github.event.head_commit.message }}
jobs:
build-and-publish:
name: Build and publish
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[ci skip release]') }}
permissions:
actions: write
contents: write
packages: write
deployments: write
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_PUBLISH_TOKEN }}
fetch-depth: "0" # fetch entire git history
- name: Fetch version tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Configure CI Git User
run: |
git config --global user.name '@fremtind-bot'
git config --global user.email '[email protected]'
git remote set-url origin https://fremtind-bot:[email protected]/fremtind/jokul
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: |
- args: [--global, lerna-clean-changelogs-cli@^2.0.18]
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Install Packages
run: |
pnpm install --frozen-lockfile
- name: Monorepo Runner Cache
uses: actions/cache@v3
id: nx-cache
with:
path: .nx
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
nx-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Try logout
continue-on-error: true
run: npm logout
- name: Verify release is needed
id: lerna_changed
continue-on-error: true
run: pnpm version:check
- name: Authenticate with Registry
if: steps.lerna_changed.outcome == 'success'
run: |
echo "registry=http://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish packages to NPM
if: steps.lerna_changed.outcome == 'success' # only run if there are changes to publish
run: pnpm release --yes
env:
GH_TOKEN: ${{ secrets.BOT_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.BOT_PUBLISH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Switch registry
if: steps.lerna_changed.outcome == 'success'
uses: actions/setup-node@v3
with:
registry-url: "https://npm.pkg.github.com"
# Defaults to the user or organization that owns the workflow file
scope: "@fremtind"
- name: Clear uncommitted changes
if: steps.lerna_changed.outcome == 'success'
run: git checkout .npmrc
- name: Reinstall packages after running actions/setup-node
run: pnpm install --frozen-lockfile
- name: Publish packages to GitHub Packages
if: steps.lerna_changed.outcome == 'success'
run: pnpm release-gh --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore registry
if: steps.lerna_changed.outcome == 'success'
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Restore workspace
if: steps.lerna_changed.outcome == 'success'
run: |
pnpm install --frozen-lockfile
- name: Build packages if needed
if: steps.lerna_changed.outcome != 'success'
run: pnpm build
- name: Build and deploy portal
env:
GATSBY_MIXPANEL_PROJECT_ID: ${{ secrets.MIXPANEL_PROJECT_ID_PROD }}
GH_TOKEN: ${{ secrets.BOT_PUBLISH_TOKEN }}
run: |
git config user.email "[email protected]"
git config user.name "fremtind-bot"
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/fremtind/jokul.git
pnpm deploy:docs
main-to-external:
name: Merge main to external-contributions
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- run: gh api --method POST /repos/fremtind/jokul/merges -F base='external-contributions' -F head='main' # do a server-side merge using GitHub API https://cli.github.com/manual/gh_api and https://docs.github.com/en/rest/reference/repos#merging
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}