Skip to content

Commit dd623f6

Browse files
authored
Merge pull request #5 from feloy/release
ci: add release workflow with cross-platform builds and version bump
2 parents fa59ebe + 4a0624b commit dd623f6

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.runner }}
11+
strategy:
12+
matrix:
13+
include:
14+
- target: x86_64-unknown-linux-gnu
15+
runner: ubuntu-24.04
16+
- target: aarch64-unknown-linux-gnu
17+
runner: ubuntu-24.04
18+
use_cross: true
19+
- target: x86_64-apple-darwin
20+
runner: macos-26
21+
- target: aarch64-apple-darwin
22+
runner: macos-26
23+
- target: x86_64-pc-windows-msvc
24+
runner: windows-2025
25+
steps:
26+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
28+
- name: Install Rust toolchain
29+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
30+
with:
31+
toolchain: stable
32+
targets: ${{ matrix.target }}
33+
34+
- name: Install cross
35+
if: matrix.use_cross == true
36+
run: cargo install cross --locked
37+
38+
- name: Build
39+
if: matrix.use_cross != true
40+
run: cargo build --release --target ${{ matrix.target }}
41+
42+
- name: Build (cross)
43+
if: matrix.use_cross == true
44+
run: cross build --release --target ${{ matrix.target }}
45+
46+
- name: Upload artifact
47+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
48+
with:
49+
name: openshell-image-builder-${{ matrix.target }}
50+
path: target/${{ matrix.target }}/release/openshell-image-builder${{ matrix.target == 'x86_64-pc-windows-msvc' && '.exe' || '' }}
51+
52+
release:
53+
needs: build
54+
runs-on: ubuntu-24.04
55+
permissions:
56+
contents: write
57+
steps:
58+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59+
60+
- name: Download artifacts
61+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
62+
with:
63+
path: artifacts
64+
merge-multiple: false
65+
66+
- name: Create GitHub release
67+
env:
68+
GH_TOKEN: ${{ github.token }}
69+
run: |
70+
gh release create "${{ github.ref_name }}" \
71+
--title "${{ github.ref_name }}" \
72+
--generate-notes \
73+
artifacts/**/*
74+
75+
bump-next-version:
76+
name: Bump Next Version
77+
runs-on: ubuntu-24.04
78+
needs: release
79+
permissions:
80+
contents: write
81+
pull-requests: write
82+
steps:
83+
- name: Checkout main branch
84+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
85+
with:
86+
ref: main
87+
88+
- name: Install Rust toolchain
89+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
90+
with:
91+
toolchain: stable
92+
93+
- name: Install cargo-edit
94+
run: cargo install cargo-edit --locked
95+
96+
- name: Compute next version
97+
id: version
98+
run: |
99+
TAG="${{ github.ref_name }}"
100+
VERSION="${TAG#v}"
101+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
102+
MINOR=$(echo "$VERSION" | cut -d. -f2)
103+
NEXT_VERSION="${MAJOR}.$((MINOR + 1)).0-next"
104+
echo "next_version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
105+
106+
- name: Bump version
107+
run: cargo set-version "${{ steps.version.outputs.next_version }}"
108+
109+
- name: Configure git
110+
run: |
111+
git config user.name "github-actions[bot]"
112+
git config user.email "github-actions[bot]@users.noreply.github.com"
113+
114+
- name: Create PR
115+
env:
116+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
run: |
118+
BRANCH="bump-next-${{ steps.version.outputs.next_version }}"
119+
git checkout -b "$BRANCH"
120+
git add Cargo.toml Cargo.lock
121+
git commit -m "chore: bump version to ${{ steps.version.outputs.next_version }}"
122+
git push origin "$BRANCH"
123+
PR_URL=$(gh pr create \
124+
--title "chore: bump version to ${{ steps.version.outputs.next_version }}" \
125+
--body "Bump version to \`${{ steps.version.outputs.next_version }}\` after release \`${{ github.ref_name }}\`." \
126+
--base main \
127+
--head "$BRANCH")
128+
echo "Pull request created: ${PR_URL}"
129+
gh pr ready "${PR_URL}"
130+
gh pr merge "${PR_URL}" --auto --rebase

0 commit comments

Comments
 (0)