Repository navigation
64 lines (60 loc) · 2.63 KB
/
Copy pathrelease.yml
File metadata and controls
64 lines (60 loc) · 2.63 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
name: Release
on:
push:
tags: ["v*"]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 15
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0
with:
ruby-version: "4.0"
bundler: default
- name: Verify tag matches gem version
run: test "v$(ruby -e 'require_relative "lib/breadkit/rspec/version"; print Breadkit::RSpec::VERSION')" = "$GITHUB_REF_NAME"
- name: Prepare release notes
run: |
version="${GITHUB_REF_NAME#v}"
awk -v version="$version" '
$0 == "## " version || index($0, "## " version " ") == 1 ||
$0 == "## [" version "]" || index($0, "## [" version "] ") == 1 { found = 1; next }
found && /^## / { exit }
found { print }
END { if (!found) exit 1 }
' CHANGELOG.md > "$RUNNER_TEMP/release-notes.md"
grep -q '[^[:space:]]' "$RUNNER_TEMP/release-notes.md"
- name: Build with strict gem validation
run: gem build --strict breadkit-rspec.gemspec --output "$RUNNER_TEMP/package.gem"
- name: Verify Breadkit dependency is published
run: gem list --remote --exact breadkit --version '~> 0.2.0' | grep -q '^breadkit ('
- name: Check whether this gem is already published
id: published
run: |
status=$(curl --silent --show-error --location --output /dev/null --write-out '%{http_code}' --head "https://rubygems.org/downloads/breadkit-rspec-${GITHUB_REF_NAME#v}.gem")
case "$status" in
200) echo 'exists=true' >> "$GITHUB_OUTPUT" ;;
404) echo 'exists=false' >> "$GITHUB_OUTPUT" ;;
*) echo "RubyGems returned HTTP $status" >&2; exit 1 ;;
esac
- name: Configure RubyGems Trusted Publishing
if: steps.published.outputs.exists == 'false'
uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0
- name: Publish breadkit-rspec
if: steps.published.outputs.exists == 'false'
run: gem push "$RUNNER_TEMP/package.gem"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --verify-tag --title "$GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/release-notes.md"