Repository navigation
113 lines (100 loc) · 3.41 KB
/
Copy pathrelease.yml
File metadata and controls
113 lines (100 loc) · 3.41 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
name: Release
# Two gems with separate reasons to change, so two tag namespaces:
# v0.1.0 publishes ruvoy
# envoy/v1.39.1 publishes ruvoy-envoy
# Both are always built, because the acceptance test needs an Envoy to run
# against; only the one the tag names is published.
on:
push:
tags:
- "v*"
- "envoy/v*"
permissions:
contents: read
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.runner }}
timeout-minutes: 40
env:
BUNDLE_WITH: test
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build both gems
run: bundle exec rake build:gem
# A gem that installs and cannot serve a request is the failure this
# whole packaging exists to prevent, so nothing is published until an
# installed copy has answered one.
- name: Install the gems and serve a request through them
run: bundle exec rake e2e:packaged_gem
- uses: actions/upload-artifact@v4
with:
name: gems-${{ matrix.arch }}
path: "*.gem"
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
- uses: actions/download-artifact@v4
with:
pattern: gems-*
merge-multiple: true
path: gems
# The tag decides which gem is released; the other was built only so the
# acceptance test had something to run against.
- name: Select the gems this tag releases
id: select
run: |
if [[ "$GITHUB_REF_NAME" == envoy/v* ]]; then
echo "glob=gems/ruvoy-envoy-*.gem" >>"$GITHUB_OUTPUT"
else
echo "glob=gems/ruvoy-[0-9]*.gem" >>"$GITHUB_OUTPUT"
fi
- name: Refuse a tag that does not match what was built
run: |
shopt -s nullglob
files=(${{ steps.select.outputs.glob }})
[[ ${#files[@]} -gt 0 ]] || { echo "no gem matches $GITHUB_REF_NAME"; exit 1; }
expected="${GITHUB_REF_NAME#envoy/}"
expected="${expected#v}"
for file in "${files[@]}"; do
[[ "$file" == *"-$expected-"* ]] ||
{ echo "$file does not carry version $expected"; exit 1; }
done
printf 'releasing:\n'; printf ' %s\n' "${files[@]}"
# Before anything is published, so a release without notes stops here.
- name: Write the release notes
run: rake "release:notes[$GITHUB_REF_NAME]" >release-notes.md
- uses: rubygems/configure-rubygems-credentials@v2.1.0
- name: Push to RubyGems
run: |
shopt -s nullglob
for file in ${{ steps.select.outputs.glob }}; do
gem push "$file"
done
- name: Attach the gems to the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --notes-file release-notes.md ${{ steps.select.outputs.glob }}