Repository navigation
131 lines (123 loc) · 4.56 KB
/
Copy pathrelease.yml
File metadata and controls
131 lines (123 loc) · 4.56 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
name: Release
# Publishes a GitHub Release for every new version in Cargo.toml: once CI
# passes on a main commit whose `v<version>` has no release yet, this builds
# the Linux and Windows archives, tags that commit, and attaches the archives
# with the version's CHANGELOG.md entry as the notes. Run it by hand
# ("Run workflow") to retry a failed publish.
# Keep shaderc-sys source builds working on runners that provide CMake 4.
env:
CMAKE_POLICY_VERSION_MINIMUM: "3.5"
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release
jobs:
version:
# A fork pull request from a branch named main also matches the trigger,
# so only release CI runs of pushes to this repository's main.
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.head_repository.full_name == github.repository)
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.check.outputs.tag }}
sha: ${{ steps.check.outputs.sha }}
new: ${{ steps.check.outputs.new }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
fetch-depth: 0
persist-credentials: false
- id: check
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
tag="v$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)"
sha="$(git rev-parse HEAD)"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
if gh release view "$tag" > /dev/null 2>&1; then
echo "$tag is already released."
echo "new=false" >> "$GITHUB_OUTPUT"
exit 0
fi
tagged="$(git rev-parse -q --verify "refs/tags/$tag^{commit}" || true)"
if [ -n "$tagged" ] && [ "$tagged" != "$sha" ]; then
echo "::error::$tag already tags $tagged, not $sha. Raise the version in Cargo.toml, or delete the unreleased tag."
exit 1
fi
echo "new=true" >> "$GITHUB_OUTPUT"
build:
needs: version
if: needs.version.outputs.new == 'true'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
archive: rusting-engine-linux-x86_64.tar.gz
- os: windows-latest
archive: rusting-engine-windows-x86_64.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.version.outputs.sha }}
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Install audio, D-Bus, and gamepad headers
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libasound2-dev libudev-dev libdbus-1-dev
- name: Build release tools
run: cargo build --release --bin editor --bin user_main --bin cook_scene
- name: Package Linux archive
if: runner.os == 'Linux'
shell: bash
run: ./scripts/package_release.sh "${{ matrix.archive }}"
- name: Package Windows archive
if: runner.os == 'Windows'
shell: pwsh
run: ./scripts/package_release.ps1 "${{ matrix.archive }}"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: dist/${{ matrix.archive }}
publish:
needs: [version, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.version.outputs.sha }}
persist-credentials: false
- name: Release notes from CHANGELOG.md
env:
TAG: ${{ needs.version.outputs.tag }}
run: |
awk -v v="${TAG#v}" '/^## \[/ { p = index($0, "## [" v "]") == 1; next } p && /^---$/ { exit } p' CHANGELOG.md > notes.md
[ -s notes.md ] || echo "No CHANGELOG.md entry for $TAG." > notes.md
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.version.outputs.tag }}
target_commitish: ${{ needs.version.outputs.sha }}
name: RustingEngine ${{ needs.version.outputs.tag }}
body_path: notes.md
files: artifacts/*