-
Notifications
You must be signed in to change notification settings - Fork 32
149 lines (131 loc) · 4.15 KB
/
Copy pathrelease.yml
File metadata and controls
149 lines (131 loc) · 4.15 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g., v0.1.0)'
required: true
env:
CARGO_INCREMENTAL: 0
jobs:
release:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
tag: ${{ steps.push-tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push tag if version changed
id: push-tag
if: steps.changesets.outputs.hasChangesets == 'false'
shell: bash
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="v$VERSION"
if ! git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Pushed tag $TAG"
else
echo "Tag $TAG already exists"
fi
build:
needs: [release]
if: always() && (needs.release.outputs.tag != '' || github.event_name == 'workflow_dispatch')
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Determine tag
id: get-tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "tag=${{ needs.release.outputs.tag }}" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
with:
ref: ${{ steps.get-tag.outputs.tag }}
submodules: recursive
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libappindicator3-dev \
librsvg2-dev \
patchelf \
libpipewire-0.3-dev \
libgbm-dev \
libxcb1-dev \
libegl-dev
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- run: pnpm install
- name: Extract changelog for current version
id: changelog
shell: bash
run: |
VERSION="${{ steps.get-tag.outputs.tag }}"
VERSION="${VERSION#v}" # Remove 'v' prefix
# Extract content between current version header and next version header
CHANGELOG=$(awk "/^## ${VERSION}\$/{found=1; next} found && /^## /{exit} found" CHANGELOG.md)
# Handle multi-line output
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ steps.get-tag.outputs.tag }}
releaseName: ${{ steps.get-tag.outputs.tag }}
releaseBody: ${{ steps.changelog.outputs.content }}
releaseDraft: false
prerelease: false
args: --target ${{ matrix.target }}