Skip to content

Commit fed30ff

Browse files
authored
Merge pull request #2 from tkumata/create-workflows
feat: Create workflows
2 parents 6c12637 + c7c0f29 commit fed30ff

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
create-release:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
upload_url: ${{ steps.create_release.outputs.upload_url }}
13+
release_id: ${{ steps.create_release.outputs.id }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get version from Cargo.toml
21+
id: get_version
22+
run: |
23+
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
24+
echo "version=v${VERSION}" >> $GITHUB_OUTPUT
25+
26+
- name: Create Release
27+
id: create_release
28+
uses: actions/create-release@v1
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
with:
32+
tag_name: ${{ steps.get_version.outputs.version }}
33+
release_name: Release ${{ steps.get_version.outputs.version }}
34+
draft: false
35+
prerelease: false
36+
37+
build:
38+
needs: create-release
39+
strategy:
40+
matrix:
41+
include:
42+
- os: ubuntu-latest
43+
target: x86_64-unknown-linux-gnu
44+
artifact_name: yomitore
45+
asset_name: yomitore-linux-x86_64
46+
- os: macos-latest
47+
target: x86_64-apple-darwin
48+
artifact_name: yomitore
49+
asset_name: yomitore-macos-x86_64
50+
- os: macos-latest
51+
target: aarch64-apple-darwin
52+
artifact_name: yomitore
53+
asset_name: yomitore-macos-aarch64
54+
55+
runs-on: ${{ matrix.os }}
56+
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Install Rust
62+
uses: actions-rs/toolchain@v1
63+
with:
64+
toolchain: stable
65+
target: ${{ matrix.target }}
66+
override: true
67+
68+
- name: Build
69+
uses: actions-rs/cargo@v1
70+
with:
71+
command: build
72+
args: --release --target ${{ matrix.target }}
73+
74+
- name: Prepare binary
75+
run: |
76+
cd target/${{ matrix.target }}/release
77+
strip ${{ matrix.artifact_name }} || true
78+
tar czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
79+
80+
- name: Upload Release Asset
81+
uses: actions/upload-release-asset@v1
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
with:
85+
upload_url: ${{ needs.create-release.outputs.upload_url }}
86+
asset_path: ./target/${{ matrix.target }}/release/${{ matrix.asset_name }}.tar.gz
87+
asset_name: ${{ matrix.asset_name }}.tar.gz
88+
asset_content_type: application/gzip

0 commit comments

Comments
 (0)