-
Notifications
You must be signed in to change notification settings - Fork 25
165 lines (146 loc) · 4.8 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (146 loc) · 4.8 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
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
name: Release
on:
push:
branches:
- main
permissions:
contents: write
packages: write
actions: read
jobs:
pre-check:
runs-on: ubuntu-22.04
outputs:
skip-workflow: ${{ steps.check.outputs.skip-workflow }}
steps:
- name: Check if workflow should be skipped
id: check
env:
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
if [[ "$COMMIT_AUTHOR" == "github-actions[bot]" ]] && [[ "$COMMIT_MESSAGE" == Release\ version* ]]; then
echo "skip-workflow=false" >> $GITHUB_OUTPUT
echo "Proceeding with this workflow..."
else
echo "skip-workflow=true" >> $GITHUB_OUTPUT
echo "Skipping this workflow..."
fi
get-version:
runs-on: ubuntu-22.04
needs: [pre-check]
if: ${{ needs.pre-check.outputs.skip-workflow == 'false' }}
outputs:
version: ${{ steps.extract.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from package.json
id: extract
run: |
version=$(yq -r '.version' package.json)
echo "version=$version" >> $GITHUB_OUTPUT
# Build the release image directly from the version-bump commit that triggered
# this workflow, so the version baked into the image (src/version.ts, generated
# from package.json at build time) matches the release tag. Previously this job
# retagged the pre-bump `main` image, which left the image reporting the prior
# version. Mirrors the build.yml invocation, adding the versioned + latest tags.
tag-release-image:
needs: [get-version]
permissions:
contents: read
packages: write
uses: docker/github-builder/.github/workflows/build.yml@v1
with:
output: image
push: true
platforms: linux/amd64,linux/arm64
meta-images: ghcr.io/${{ github.repository }}
meta-tags: |
type=raw,value=v${{ needs.get-version.outputs.version }}
type=raw,value=latest
sign: false
cache: true
secrets:
registry-auths: |
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
add-release-artifacts:
runs-on: ubuntu-22.04
needs: [tag-release-image, get-version]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download macOS MCPB artifact
uses: dawidd6/action-download-artifact@688efa90a08f3552e7c1420c8313e215164e8b14
with:
workflow: build-mcpb.yml
name: tomtom-maps-mcp-darwin-arm64
path: ./dist/mcpb
branch: main
search_artifacts: true
- name: Download Linux MCPB artifact
uses: dawidd6/action-download-artifact@688efa90a08f3552e7c1420c8313e215164e8b14
with:
workflow: build-mcpb.yml
name: tomtom-maps-mcp-linux-x64
path: ./dist/mcpb
branch: main
search_artifacts: true
- name: Download Windows MCPB artifact
uses: dawidd6/action-download-artifact@688efa90a08f3552e7c1420c8313e215164e8b14
with:
workflow: build-mcpb.yml
name: tomtom-maps-mcp-win32-x64
path: ./dist/mcpb
branch: main
search_artifacts: true
- name: List downloaded artifacts
run: ls -la ./dist/mcpb/
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.get-version.outputs.version }}
files: |
./dist/mcpb/tomtom-maps-mcp-darwin-arm64.mcpb
./dist/mcpb/tomtom-maps-mcp-linux-x64.mcpb
./dist/mcpb/tomtom-maps-mcp-win32-x64.mcpb
publish-npm:
runs-on: ubuntu-22.04
needs: [tag-release-image]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Print package.json details
run: |
cat package.json
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
cleanup:
runs-on: ubuntu-22.04
if: always() && needs.pre-check.outputs.skip-workflow == 'false'
needs: [pre-check]
steps:
- uses: dataaxiom/ghcr-cleanup-action@cd0cdb900b5dbf3a6f2cc869f0dbb0b8211f50c4
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude-tags: '^v[0-9]+\.[0-9]+\.[0-9]+$'
use-regex: true
keep-n-tagged: 30
log-level: info