-
Notifications
You must be signed in to change notification settings - Fork 2k
169 lines (165 loc) · 6.55 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Release
on:
pull_request_review:
types: [submitted]
env:
YARN_ENABLE_GLOBAL_CACHE: false
jobs:
release:
name: Publish releases
if:
${{ github.event.review.state == 'approved' && github.event.sender.login
== github.event.pull_request.assignee.login &&
github.event.pull_request.head.ref == 'release-candidate' }}
outputs:
companionWasReleased:
${{ steps.checkIfCompanionWasReleased.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: corepack yarn install --immutable
env:
# https://docs.cypress.io/guides/references/advanced-installation#Skipping-installation
CYPRESS_INSTALL_BINARY: 0
- name: Get CHANGELOG diff
run:
git --no-pager diff HEAD^ -- CHANGELOG.md | awk '{ if( substr($0,0,1)
== "+" && $1 != "+##" && $1 != "+Released:" && $1 != "+++" ) { print
substr($0,2) } }' > CHANGELOG.diff.md
- name: Copy README for `uppy` package
run: cp README.md packages/uppy/.
- name: Build before publishing
run: corepack yarn run build
- name: Hack to allow the publish of the Angular package
run: corepack yarn workspace @uppy/angular prepublishOnly
- name: Publish to the npm registry
run:
corepack yarn workspaces foreach --all --no-private npm publish
--access public --tolerate-republish
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Merge PR
id: merge
run: |
gh api -X PUT repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge \
-F merge_method="squash" \
-F commit_message="$(cat CHANGELOG.diff.md)" \
--jq 'if .merged then "sha="+.sha else error("not merged") end' >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tags
run: |
git --no-pager diff --name-only HEAD^ | awk '$0 ~ /^packages\/.+\/package\.json$/ { print "jq -r '"'"'\"gh api /repos/{owner}/{repo}/git/refs -f ref=\\\"refs/tags/\"+.name+\"@\"+.version+\"\\\" -f sha=${{ steps.merge.outputs.sha }}\"'"'"' < " $0 }' > createTags.sh
cat createTags.sh
sh createTags.sh | sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Uppy version number
id: uppyVersion
run:
jq -r '"version="+.version' < packages/uppy/package.json >>
$GITHUB_OUTPUT
- name: Create GitHub release
run:
gh release create uppy@${{ steps.uppyVersion.outputs.version }} -t
"Uppy ${{ steps.uppyVersion.outputs.version }}" -F CHANGELOG.diff.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload `uppy` to CDN
run: corepack yarn run uploadcdn uppy
env:
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
- name: Upload `@uppy/locales` to CDN if it was released
run:
git diff --exit-code --quiet HEAD^ --
packages/@uppy/locales/package.json ||corepack yarn run uploadcdn
@uppy/locales
env:
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
- name: Check if Companion was released
id: checkIfCompanionWasReleased
run:
git diff --exit-code --quiet HEAD^ --
packages/@uppy/companion/package.json || echo "version=$(jq -r
.version < packages/@uppy/companion/package.json)" >> $GITHUB_OUTPUT
- name: Remove release-candidate branch
run:
gh api -X DELETE repos/${{ github.repository
}}/git/refs/heads/release-candidate || echo "Already deleted"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove release branch
run:
gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Disable Release workflow
run: gh workflow disable Release --repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: In case of failure
if: ${{ failure() }}
run:
gh pr comment ${{ github.event.pull_request.number }} --body "Release
job failed, please take action."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# See also companion-deploy.yml
docker:
name: DockerHub
needs: release
if: ${{ needs.release.outputs.companionWasReleased }}
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 0
COMPOSE_DOCKER_CLI_BUILD: 0
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: transloadit/companion
tags: |
type=edge
type=semver,pattern={{version}},value=${{ needs.release.outputs.companionWasReleased }}
# set latest tag for default branch
type=raw,value=latest,enable=true
- uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- uses: docker/setup-buildx-action@v3
- name: Log in to DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- name: Build and push
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}