-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (102 loc) · 3.5 KB
/
release.yaml
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
name: Release
on:
push:
branches:
- workflow_release
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha'
- 'v[0-9]+.[0-9]+.[0-9]+-beta'
env:
# Emit backtraces on panics.
RUST_BACKTRACE: full
# Enable colors in cargo output.
CARGO_TERM_COLOR: always
# Use sparse index if supported - unlikely with the MSRV?
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# Disable incremental compilation.
CARGO_INCREMENTAL: 0
jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: crates.io
steps:
- name: Get release information
id: info
run: |
ref_name='${{ github.ref_name }}'
echo "ref_name: $ref_name"
# is this a test release, or a real release?
if [[ "$ref_name" == 'workflow_release' ]]; then
version='v0.0.0-test'
target_commitish='${{ github.sha }}'
draft='true'
dry_run='--dry-run'
else
version="$ref_name"
target_commitish=''
draft='false'
dry_run=''
fi
echo "version: $version"
echo "target_commitish: $target_commitish"
echo "draft: $draft"
echo "dry_run: $dry_run"
# is this a pre-release (-rc*, -alpha, -beta, -test)?
if [[ "$version" == *"-"* ]]; then
prerelease='true'
else
prerelease='false'
fi
echo "prerelease: $prerelease"
date=$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')
echo "date: $date"
echo "version=$version" >> $GITHUB_OUTPUT
echo "target_commitish=$target_commitish" >> $GITHUB_OUTPUT
echo "draft=$draft" >> $GITHUB_OUTPUT
echo "dry_run=$dry_run" >> $GITHUB_OUTPUT
echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
echo "date=$date" >> $GITHUB_OUTPUT
shell: bash
- name: Checkout repository
uses: actions/checkout@v3
- name: Sync toolchain
run: rustup show
shell: bash
- name: Run cargo check (debug)
run: RUSTFLAGS="-D warnings" cargo check --workspace
shell: bash
- name: Run cargo check (release)
run: cargo check --workspace --release
shell: bash
- name: Create GitHub release
id: release
run: |
curl \
--fail \
--request 'POST' \
--url '${{ github.api_url }}/repos/${{ github.repository }}/releases' \
--header 'Accept: application/vnd.github+json' \
--header 'Authorization: Bearer ${{ github.token }}' \
--header 'Content-type: application/json' \
--data '{
"tag_name": "${{ steps.info.outputs.version }}",
"target_commitish": "${{ steps.info.outputs.target_commitish }}",
"name": "${{ steps.info.outputs.version }} (${{ steps.info.outputs.date }})",
"prerelease": ${{ steps.info.outputs.prerelease }},
"draft": ${{ steps.info.outputs.draft }}
}' \
--output 'release.json'
cat release.json
shell: bash
- name: Run cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish ${{ steps.info.outputs.dry_run }}
shell: bash
- name: Show published files
continue-on-error: true
run: tar tf target/package/lcid-*.crate
shell: bash