-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (102 loc) · 3.46 KB
/
release.yml
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
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-release:
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_name: lazydraft-linux-amd64
executable_name: lazydraft
- os: macos-latest
target: x86_64-apple-darwin
asset_name: lazydraft-macos-amd64
executable_name: lazydraft
- os: windows-latest
target: x86_64-pc-windows-msvc
asset_name: lazydraft-windows-amd64.exe
executable_name: lazydraft.exe
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --target ${{ matrix.target }}
- name: Package Binary (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ matrix.asset_name }}.tar.gz ${{ matrix.executable_name }}
cd ../../..
- name: Package Binary (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.asset_name }}.zip ${{ matrix.executable_name }}
cd ../../..
- name: Upload Release Asset (Unix)
if: matrix.os != 'windows-latest'
uses: softprops/action-gh-release@v1
with:
files: ${{ matrix.asset_name }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset (Windows)
if: matrix.os == 'windows-latest'
uses: softprops/action-gh-release@v1
with:
files: ${{ matrix.asset_name }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clone Homebrew Tap
if: matrix.os == 'macos-latest'
run: |
git clone https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/yigitozgumus/homebrew-formulae.git
cd homebrew-formulae
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Update Formula
if: matrix.os == 'macos-latest'
run: |
cd homebrew-formulae
cd Formula
sed -i '' "s|url .*|url \"https://github.com/yigitozgumus/lazydraft/releases/download/${{ github.event.release.tag_name }}/lazydraft-v${{ github.event.release.tag_name }}.tar.gz\"|" lazydraft.rb
sed -i '' "s|sha256 .*|sha256 \"${{ steps.sha256.outputs.sha256 }}\"|" lazydraft.rb
git add lazydraft.rb
git commit -m "Update lazydraft formula for version ${{ github.event.release.tag_name }}"
git push https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/yigitozgumus/homebrew-formulae.git main