-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (154 loc) · 4.9 KB
/
release.yml
File metadata and controls
179 lines (154 loc) · 4.9 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Release
on:
workflow_dispatch:
env:
JAVA_VERSION: 21
jobs:
release:
permissions:
contents: write
packages: write
outputs:
release_tag: ${{ steps.tag_commit.outputs.release_tag }}
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ steps.app-token.outputs.token }}
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
cache: 'gradle'
- name: Switch to release
run: |
./gradlew switchToRelease
- name: Build uber-jar
run: ./gradlew build -Dquarkus.package.jar.type=uber-jar
- name: Commit changes
shell: bash
run: |
VERSION=$(grep "switchBotMcpServerVersion=" gradle.properties | cut -d'=' -f2)
git config user.name "sharplab-bot"
git config user.email "actions@github.com"
git add .
git commit --allow-empty -m "Release ${VERSION}"
- name: Push commit
shell: bash
run: |
git fetch
git rebase origin/master
git push
- name: Tag commit
id: tag_commit
shell: bash
run: |
VERSION=$(grep "switchBotMcpServerVersion=" gradle.properties | cut -d'=' -f2)
TAG="${VERSION}.RELEASE"
git tag "${TAG}"
echo "release_tag=${TAG}" >> $GITHUB_OUTPUT
- name: Push tag
shell: bash
run: |
git push origin "${{ steps.tag_commit.outputs.release_tag }}"
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_commit.outputs.release_tag }}
release_name: Release ${{ steps.tag_commit.outputs.release_tag }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./switchbot-mcp-server/build/switchbot-mcp-server.jar
asset_name: switchbot-mcp-server.jar
asset_content_type: application/java-archive
push-to-ghcr:
permissions:
contents: read
packages: write
needs:
- release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.release_tag }}
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ needs.release.outputs.release_tag }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./switchbot-mcp-server/src/main/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: true
sbom: true
push-to-quay:
permissions:
contents: read
packages: write
needs:
- release
runs-on: ubuntu-latest
env:
REGISTRY: quay.io
IMAGE: sharplab/switchbot-mcp-server
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.release_tag }}
- name: Log in to Quay.io
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_BOT_USERNAME }}
password: ${{ secrets.QUAY_BOT_TOKEN }}
- name: Build image (buildah)
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE }}
tags: ${{ needs.release.outputs.release_tag }}
containerfiles: |
./switchbot-mcp-server/src/main/docker/Dockerfile
context: .
- name: Push to Quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.REGISTRY }}