Skip to content

Commit 4f900ce

Browse files
committed
refactor(#4): separate build and release flows
1 parent d1a4f41 commit 4f900ce

File tree

2 files changed

+44
-119
lines changed

2 files changed

+44
-119
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
name: Build and Release an SDK Generator
1+
name: Build and Test
22

33
on:
4+
workflow_dispatch:
5+
workflow_call:
46
push:
5-
branches:
6-
- main
7-
# FIXME drop this!!
7+
branches: [main]
88
pull_request:
9-
branches:
10-
- main
11-
12-
concurrency:
13-
group: ${{ github.workflow }}-${{ github.ref }}
14-
cancel-in-progress: true
9+
branches: [main]
1510

1611
jobs:
1712
build-jar:
@@ -93,112 +88,3 @@ jobs:
9388
with:
9489
name: build-${{ matrix.os }}
9590
path: ./aidbox-sdk-*
96-
97-
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- #
98-
99-
create-release:
100-
name: Release new version
101-
runs-on: ubuntu-latest
102-
needs: [build-jar, build-native]
103-
permissions:
104-
contents: write
105-
106-
steps:
107-
- uses: actions/checkout@v4
108-
109-
- name: Download artifacts
110-
uses: actions/download-artifact@v4
111-
with:
112-
pattern: build-*
113-
path: release/
114-
merge-multiple: true
115-
116-
- name: Fetch all tags
117-
run: git fetch --tags
118-
119-
- name: Determine next version
120-
id: next_version
121-
run: |
122-
# Get the latest tag
123-
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
124-
echo "Latest tag: $latest_tag"
125-
126-
if [ -z "$latest_tag" ]; then
127-
next_version="v1"
128-
else
129-
# Parse the version number
130-
IFS='.' read -r -a version_parts <<< "${latest_tag:1}"
131-
major=${version_parts[0]}
132-
minor=${version_parts[1]}
133-
patch=${version_parts[2]}
134-
135-
# Increment the patch version
136-
patch=$((patch + 1))
137-
138-
next_version="v$major.$minor.$patch"
139-
fi
140-
141-
echo "Next version: $next_version"
142-
echo "tag=$next_version" >> $GITHUB_OUTPUT
143-
144-
- name: Create a new tag
145-
run: |
146-
git tag ${{ steps.next_version.outputs.tag }}
147-
git push origin ${{ steps.next_version.outputs.tag }}
148-
149-
# FIXME this action is archived
150-
- name: Create Github Release
151-
id: create_release
152-
uses: actions/create-release@v1
153-
env:
154-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155-
with:
156-
tag_name: ${{ steps.next_version.outputs.tag }}
157-
release_name: Release ${{ steps.next_version.outputs.tag }}
158-
draft: false
159-
prerelease: false
160-
161-
# FIXME this action is archived
162-
# FIXME do not enumarote files in reales manually
163-
- name: Upload Release Asset (jar)
164-
uses: actions/upload-release-asset@v1
165-
env:
166-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167-
with:
168-
upload_url: ${{ steps.create_release.outputs.upload_url }}
169-
asset_path: release/aidbox-sdk.jar
170-
asset_name: aidbox-sdk.jar
171-
asset_content_type: application/java-archive
172-
173-
# FIXME this action is archived
174-
- name: Upload Release Asset (amd64)
175-
uses: actions/upload-release-asset@v1
176-
env:
177-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
178-
with:
179-
upload_url: ${{ steps.create_release.outputs.upload_url }}
180-
asset_path: release/aidbox-sdk-ubuntu-latest
181-
asset_name: aidbox-sdk-linux
182-
asset_content_type: application/octet-stream
183-
184-
# FIXME this action is archived
185-
- name: Upload Release Asset (arm64)
186-
uses: actions/upload-release-asset@v1
187-
env:
188-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
189-
with:
190-
upload_url: ${{ steps.create_release.outputs.upload_url }}
191-
asset_path: release/aidbox-sdk-macos-latest
192-
asset_name: aidbox-sdk-macos-m1
193-
asset_content_type: application/octet-stream
194-
195-
# FIXME this action is archived
196-
- name: Upload Release Assets (Windows)
197-
uses: actions/upload-release-asset@v1
198-
env:
199-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
200-
with:
201-
upload_url: ${{ steps.create_release.outputs.upload_url }}
202-
asset_path: release/aidbox-sdk-windows-latest.exe
203-
asset_name: aidbox-sdk-windows.exe
204-
asset_content_type: application/octet-stream

.github/workflows/release.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release an SDK Generator
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
build:
13+
uses: ./.github/workflows/build.yaml
14+
secrets: inherit
15+
16+
create-release:
17+
name: Release new version
18+
runs-on: ubuntu-latest
19+
if: ${{ github.event_name == 'release' }}
20+
needs: [build]
21+
permissions:
22+
contents: write
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Download artifacts
28+
uses: actions/download-artifact@v4
29+
with:
30+
pattern: build-*
31+
path: release/
32+
merge-multiple: true
33+
34+
- name: Upload release assets
35+
uses: AButler/[email protected]
36+
with:
37+
files: "release/*"
38+
repo-token: ${{ secrets.GITHUB_TOKEN }}
39+
release-id: ${{ github.event.release.id }}

0 commit comments

Comments
 (0)