Skip to content

Commit 09cea58

Browse files
Adopt release workflow from rabbitmq/fshc
1 parent 1729285 commit 09cea58

File tree

1 file changed

+116
-49
lines changed

1 file changed

+116
-49
lines changed

.github/workflows/release.yaml

+116-49
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,138 @@
1-
name: Deploy
1+
name: Release
22

33
on:
4+
workflow_dispatch:
45
push:
56
tags:
6-
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- 'v\d\.\d\.\d'
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
permissions:
14+
contents: write
15+
716
jobs:
8-
build-and-upload:
9-
name: Buidl and upload
10-
runs-on: $${{ matrix.os }}
17+
release:
18+
name: Build and Archive
19+
20+
runs-on: ${{ matrix.os }}
1121

1222
strategy:
1323
matrix:
1424
include:
15-
- build: linux
16-
os: ubuntu-latest
17-
target: x86_64-unknown-linux-musl
18-
19-
- build: macos
25+
# macOS, aarch64
26+
- target: aarch64-apple-darwin
2027
os: macos-latest
21-
target: x86_64-apple-darwin
22-
23-
- build: windows-gnu
28+
target_rustflags: ''
29+
# Windoze, x86-64
30+
- target: x86_64-pc-windows-gnu
2431
os: windows-latest
25-
target: x86_64-pc-windows-gnu
32+
target_rustflags: ''
33+
# Linux, x86-64
34+
- target: x86_64-unknown-linux-gnu
35+
os: ubuntu-latest
36+
target_rustflags: ''
37+
38+
permissions:
39+
id-token: write
40+
contents: write
2641

2742
steps:
28-
- name: Clone repository
29-
uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
3044

31-
- name: Install Rust toolchain
45+
- name: Install Rust toolchains
3246
uses: dtolnay/rust-toolchain@beta
3347
with:
34-
targets: ${{ matrix.target }}
48+
toolchain: beta
49+
targets: ${{ matrix.target }}
3550

36-
- name: Extract release version
37-
shell: bash
38-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
39-
40-
- name: Build
41-
uses: actions-rs/cargo@v1
51+
- name: Install Nu Shell
52+
uses: hustcer/setup-nu@v3
4253
with:
43-
use-cross: true
44-
command: build
45-
args: --verbose --release --target ${{ matrix.target }}
54+
version: '0.100'
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4657

47-
- name: Archive
48-
shell: bash
49-
run: |
50-
tool_name = "rabbitmqadmin"
51-
dirname="$tool_name-${{ env.VERSION }}-${{ matrix.target }}"
52-
mkdir "$dirname"
53-
if [ "${{ matrix.os }}" = "windows-latest" ]; then
54-
mv "target/${{ matrix.target }}/release/$tool_name.exe" "$dirname"
55-
else
56-
mv "target/${{ matrix.target }}/release/$tool_name" "$dirname"
57-
fi
58+
- name: Build an rabbitmqadmin release archive on macOS
59+
id: release-build-macos
60+
if: ${{ matrix.os == 'macos-latest' }}
61+
run: nu ./scripts/release-macos.nu
62+
env:
63+
OS: ${{ matrix.os }}
64+
TARGET: ${{ matrix.target }}
65+
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
66+
SRC: ${{ github.workspace }}
67+
- name: Store macOS build artifact
68+
id: upload-macos-artifact
69+
if: ${{ matrix.os == 'macos-latest' }}
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: "rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-${{ matrix.target }}.tar.gz"
73+
path: "${{ github.workspace }}/target/${{ matrix.target }}/release/rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-${{ matrix.target }}.tar.gz"
74+
retention-days: 2
5875

59-
if [ "${{ matrix.os }}" = "windows-latest" ]; then
60-
7z a "$dirname.zip" "$dirname"
61-
echo "ARCHIVE=$dirname.zip" >> $GITHUB_ENV
62-
else
63-
tar -czf "$dirname.tar.gz" "$dirname"
64-
echo "ARCHIVE=$dirname.tar.gz" >> $GITHUB_ENV
65-
fi
76+
- name: Build an rabbitmqadmin release archive on Linux
77+
id: release-build-linux
78+
if: ${{ matrix.os == 'ubuntu-latest' }}
79+
run: nu ./scripts/release-linux.nu
80+
env:
81+
OS: ${{ matrix.os }}
82+
TARGET: ${{ matrix.target }}
83+
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
84+
SRC: ${{ github.workspace }}
85+
- name: Store Linux build artifact
86+
id: upload-linux-artifact
87+
if: ${{ matrix.os == 'ubuntu-latest' }}
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: "rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-${{ matrix.target }}.tar.gz"
91+
path: "${{ github.workspace }}/target/${{ matrix.target }}/release/rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-${{ matrix.target }}.tar.gz"
92+
retention-days: 2
6693

67-
- name: Upload
68-
uses: softprops/action-gh-release@v1
94+
- name: Build an rabbitmqadmin release archive on Windows
95+
id: release-build-windows
96+
if: ${{ matrix.os == 'windows-latest' }}
97+
run: nu ./scripts/release-windows.nu
98+
env:
99+
OS: ${{ matrix.os }}
100+
TARGET: ${{ matrix.target }}
101+
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
102+
SRC: ${{ github.workspace }}
103+
- name: Store Windows build artifact
104+
id: upload-windows-artifact
105+
if: ${{ matrix.os == 'windows-latest' }}
106+
uses: actions/upload-artifact@v4
69107
with:
70-
files: |
71-
${{ env.ARCHIVE }}
108+
name: "rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-${{ matrix.target }}.zip"
109+
path: "${{ github.workspace }}/target/${{ matrix.target }}/release/rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-${{ matrix.target }}.zip"
110+
retention-days: 2
111+
112+
create_gh_release:
113+
needs: [release]
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Fetch macOS archive
117+
uses: actions/download-artifact@v4
118+
with:
119+
name: "rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-aarch64-apple-darwin.tar.gz"
120+
path: ./artifacts
121+
- name: Fetch Linux archive
122+
uses: actions/download-artifact@v4
123+
with:
124+
name: "rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-x86_64-unknown-linux-gnu.tar.gz"
125+
path: ./artifacts
126+
- name: Fetch Windows archive
127+
uses: actions/download-artifact@v4
128+
with:
129+
name: "rabbitmqadmin-${{ vars.NEXT_RELESE_VERSION }}-x86_64-pc-windows-gnu.zip"
130+
path: ./artifacts
131+
- name: Publish rabbitmqadmin release archive
132+
uses: softprops/action-gh-release@v2
133+
with:
134+
tag_name: v${{ vars.NEXT_RELESE_VERSION }}
135+
draft: false
136+
files: ./artifacts/*
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)