-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (114 loc) · 4.07 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
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Generate changelog
uses: orhun/git-cliff-action@v2
with:
config: cliff.toml
args: --latest --strip header
- name: Read changelog
id: changelog
run: |
echo "changelog<<EOF" >> $GITHUB_OUTPUT
cat git-cliff/CHANGELOG.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
build-release:
needs: create-release
strategy:
matrix:
include:
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
binary_name: dc
asset_name: decent-cloud-linux-amd64
- os: macos-latest
target: aarch64-apple-darwin
binary_name: dc
asset_name: decent-cloud-darwin-arm64
- os: ubuntu-20.04
target: x86_64-pc-windows-gnu
binary_name: dc.exe
asset_name: decent-cloud-windows-amd64.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'x86_64-pc-windows-gnu'
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64
- name: Build Release Binary
run: |
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
cargo install cross --git https://github.com/cross-rs/cross
cross build --release --target ${{ matrix.target }} --bin dc
else
cargo build --release --target ${{ matrix.target }} --bin dc
fi
- name: Prepare binary
run: |
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.asset_name }}
else
cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.asset_name }}
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Release ${{ github.ref_name }}
body: |
## Changelog
${{ needs.create-release.outputs.changelog }}
files: |
${{ matrix.asset_name }}
draft: false
prerelease: false
update-version:
needs: [create-release, build-release]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Update version in Cargo.toml files
run: |
VERSION="${{ needs.create-release.outputs.version }}"
for toml in $(find . -name "Cargo.toml"); do
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" "$toml"
done
timeout 10 cargo check || true
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
# Use PAT instead of GITHUB_TOKEN for PR creation to avoid error
# Error: GitHub Actions is not permitted to create or approve pull requests.
token: ${{ secrets.DC_REPO_WRITE }}
commit-message: "chore: bump version to ${{ needs.create-release.outputs.version }}"
title: "chore: bump version to ${{ needs.create-release.outputs.version }}"
body: |
Updates version in Cargo.toml+lock files to match the latest release.
This PR was automatically created by the release workflow.
branch: bump-version-${{ needs.create-release.outputs.version }}
base: main