-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (132 loc) · 4.86 KB
/
Copy pathrust-release.yml
File metadata and controls
133 lines (132 loc) · 4.86 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
name: Release
on:
workflow_call:
inputs:
runner:
type: string
default: ${{ vars.RUNNER }}
required: false
version:
type: string
required: true
package:
type: string
required: true
cargo-release-args:
type: string
required: false
default: ''
jobs:
config:
runs-on: ${{ inputs.runner || vars.RUNNER }}
name: generate config
outputs:
config: ${{ steps.config.outputs.config }}
steps:
- name: config
id: config
uses: carteramesh/ci/.github/actions/rust-config@main
with:
git_token: ${{ github.token }}
release:
needs: [config]
outputs:
tag: ${{ steps.release.outputs.tag }}
runs-on: ${{ vars.RUNNER }}
permissions:
contents: write
steps:
- name: Init
uses: carteramesh/ci/.github/actions/rust-init@main
with:
packages: ${{ toJSON(fromJSON(needs.config.outputs.config).global.packages) }}
- name: Install cargo-release
uses: taiki-e/install-action@v2
with:
tool: cargo-release
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Release
id: release
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NO_PUBLISH: ${{ fromJSON(needs.config.outputs.config).release.cargoPublish && '' || '--no-publish' }}
run: |
cargo release \
--package ${{ inputs.package }} \
--execute \
--no-confirm ${NO_PUBLISH} \
${{ inputs.cargo-release-args }} ${{ inputs.version }}
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> $GITHUB_OUTPUT
make_latest="true"
case ${{ inputs.version }} in
alpha|beta|rc)
make_latest="false"
prerelease="true"
;;
*)
make_latest="true"
prerelease="false"
;;
esac
echo "make_latest=$make_latest" >> $GITHUB_OUTPUT
echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release.outputs.tag }}
generate_release_notes: true
make_latest: ${{ steps.release.outputs.make_latest }}
prerelease: ${{ steps.release.outputs.prerelease == 'true' }}
bin:
name: assets / ${{ matrix.target }}
if: ${{ fromJSON(needs.config.outputs.config).release.bin }}
needs: [config, release]
strategy:
matrix:
include: ${{ fromJSON(toJSON(fromJSON(needs.config.outputs.config).release.os)) }}
runs-on: ${{ matrix.os }}
steps:
- name: Init / ${{ matrix.target }}
uses: carteramesh/ci/.github/actions/rust-init@main
with:
packages: ${{ toJSON(fromJSON(needs.config.outputs.config).global.packages) }}
ref: ${{ needs.release.outputs.tag }}
- name: Build / ${{ matrix.target }}
id: build
run: |
if [ ${{ fromJSON(needs.config.outputs.config).release.debian }} == "true" ] && [ "${RUNNER_OS}" != "macOS" ]; then
cargo install cargo-deb
cargo deb --target ${{ matrix.target }}
echo _dpkg="$(ls target/debian/*.deb)" >> $GITHUB_OUTPUT
else
cargo build --release --target ${{ matrix.target }}
fi
echo _bin=target/${{ matrix.target }}/release/${{ fromJSON(needs.config.outputs.config).release.bin }} >> $GITHUB_OUTPUT
- name: Package / ${{ matrix.target }}
run: |
tar czf ${{ steps.build.outputs._bin }}-${{ matrix.target }}.tar.gz ${{ steps.build.outputs._bin }}
sha256sum ${{ steps.build.outputs._bin }}-${{ matrix.target }}.tar.gz > ${{ steps.build.outputs._bin }}-${{ matrix.target }}.tar.gz.sha256
- name: Hash Deb / ${{ matrix.target }}
if: ${{ steps.build.outputs._dpkg }}
run: |
sha256sum ${{ steps.build.outputs._dpkg }} > ${{ steps.build.outputs._dpkg }}.sha256
- name: Upload / ${{ matrix.target }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release.outputs.tag }}
files: |
${{ steps.build.outputs._bin }}-${{ matrix.target }}.tar.gz
${{ steps.build.outputs._bin }}-${{ matrix.target }}.tar.gz.sha256
- name: Deb Upload / ${{ matrix.target }}
if: ${{ steps.build.outputs._dpkg }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release.outputs.tag }}
files: |
${{ steps.build.outputs._dpkg }}
${{ steps.build.outputs._dpkg }}.sha256