forked from owainlewis/push
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (96 loc) · 2.95 KB
/
Copy pathrelease.yml
File metadata and controls
114 lines (96 loc) · 2.95 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to release, for example v0.1.0"
required: true
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
validate:
name: validate release tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Check tag matches package version
env:
RELEASE_TAG: ${{ github.event.inputs.tag || github.ref_name }}
run: |
if ! git rev-parse --verify --quiet "refs/tags/${RELEASE_TAG}^{commit}"; then
echo "release ref '${RELEASE_TAG}' is not an existing Git tag" >&2
exit 1
fi
scripts/check-release-version.sh "${RELEASE_TAG}"
build:
name: build release (${{ matrix.os }})
needs: validate
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
- name: Build
run: cargo build --locked --release
- name: Package
shell: bash
run: |
set -euo pipefail
tag="${{ github.event.inputs.tag || github.ref_name }}"
target="$(rustc -Vv | awk '/host:/ { print $2 }')"
package="push-${tag}-${target}"
mkdir -p "dist/${package}"
cp target/release/push "dist/${package}/"
cp README.md LICENSE config.toml.example install.sh "dist/${package}/"
tar -C dist -czf "dist/${package}.tar.gz" "${package}"
shasum -a 256 "dist/${package}.tar.gz" > "dist/${package}.tar.gz.sha256"
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}
path: dist/*.tar.gz*
if-no-files-found: error
publish:
name: publish release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- uses: actions/download-artifact@v4
with:
pattern: release-*
path: dist
merge-multiple: true
- name: Publish GitHub release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event.inputs.tag || github.ref_name }}
run: |
set -euo pipefail
if gh release view "${TAG}" >/dev/null 2>&1; then
gh release upload "${TAG}" dist/* --clobber
else
gh release create "${TAG}" dist/* \
--title "${TAG}" \
--verify-tag \
--generate-notes
fi