-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (118 loc) · 4.48 KB
/
release.yml
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
name: Release # This name is used by the publish-docker workflow
on:
push:
tags:
- 'scip-ruby-v*'
jobs:
build-and-upload-artifacts:
name: 'Build and upload artifacts'
strategy:
matrix:
platform: ['ubuntu-20.04-16core-graph-team', 'macos-13-xlarge']
config: ['asserts', 'release']
runs-on: ${{ matrix.platform }}
env:
TAG: ${{ github.event.ref }}
steps:
- uses: actions/checkout@v4
# Keep in sync with ci.yml
- uses: ruby/setup-ruby@v1
- name: Manually evict cache entry if applicable
if: ${{ runner.os == 'Linux' }}
run: ACCESS_TOKEN='${{ secrets.GITHUB_TOKEN }}' python3 .github/workflows/evict.py
- name: "🚀 Mount Bazel build cache"
if: ${{ runner.os == 'Linux' }}
uses: actions/cache@v4
with:
path: ~/bazelcache/build
key: bazel-build-${{ runner.os }}-${{ github.sha }}
restore-keys: |
bazel-build-${{ runner.os }}-
bazel-build-
- name: "🚀 Mount Bazel repo cache"
uses: actions/cache@v4
if: ${{ runner.os == 'Linux' }}
with:
path: ~/bazelcache/repos
key: bazel-repos-${{ runner.os }}-${{ hashFiles('WORKSPACE') }}
restore-keys: |
bazel-repos-${{ runner.os }}-
bazel-repos-
- name: "⚙️ Setup Bazel"
run: VERSION="${GITHUB_REF/refs\/tags\/scip-ruby-v/}" .github/workflows/setup-bazel.sh
- name: "🔎 Identify OS"
run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
- name: ${{ format('🏗 Build ({0})', matrix.config) }}
run: |
CONFIG="dev"
if [ "$CFG" == "release" ]; then
CONFIG="release-${OS/darwin/mac}"
fi
./bazel build //main:scip-ruby --config="$CONFIG" --execution_log_binary_file=log
echo "config=$CONFIG" >> "$GITHUB_ENV"
env:
OS: ${{ env.OS }}
CFG: ${{ matrix.config }}
- name: "🪵 Upload log"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config }}-build-log
path: log
- name: ${{ format('🪄 Rename binary ({0})', matrix.config) }}
run: |
SUFFIX="-asserts"
if [ "$CFG" == "release" ]; then
SUFFIX=""
fi
outBinaryPath="scip-ruby${SUFFIX}-$(uname -m)-$OS"
cp bazel-bin/main/scip-ruby "$outBinaryPath"
echo "outBinaryPath=$outBinaryPath" >> "$GITHUB_ENV"
echo "suffix=$SUFFIX" >> "$GITHUB_ENV"
env:
OS: ${{ env.OS }}
CFG: ${{ matrix.config }}
- name: ${{ format('📦 Store binary ({0})', matrix.config) }}
uses: actions/upload-artifact@v4
with:
name: artifacts-binary-${{ matrix.platform }}-${{ matrix.config }}
path: ${{ env.outBinaryPath }}
- name: ${{ format('💎 Build Gem(s) ({0})', matrix.config) }}
run: ./bazel build //gems/scip-ruby --config="${{ env.config }}"
- name: ${{ format('📦 Store Gem(s) to GitHub ({0})', matrix.config) }}
uses: actions/upload-artifact@v4
with:
name: artifacts-gem-${{ matrix.platform }}-${{ matrix.config }}
path: bazel-bin/gems/scip-ruby/*.gem
create-release:
name: 'Create release'
needs: build-and-upload-artifacts
runs-on: 'ubuntu-20.04'
steps:
- uses: actions/checkout@v4
- name: Create Release
run: |
TAG="${GITHUB_REF/refs\/tags\//}"
TITLE="${TAG/-v/ v}"
TEMPLATE="$(< .github/workflows/release-template.md)"
echo "${TEMPLATE//TAG_PLACEHOLDER/$TAG}" > notes
gh release create "$TAG" --title "$TITLE" --notes-file notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Download everything to avoid spelling out the different
# platforms here.
- name: '📥 Download all artifacts'
uses: actions/download-artifact@v4
with:
pattern: artifacts-*
path: release-artifacts
merge-multiple: true
- name: '📤 Upload artifacts for release'
run: gh release upload "${GITHUB_REF/refs\/tags\//}" ./release-artifacts/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# There is also publish-manual.yml in case that is needed for some reason.
- name: 'Publish gems'
run: |
for g in ./release-artifacts/**.gem; do
GEM_HOST_API_KEY=${{ secrets.RUBYGEMS_API_KEY }} gem push "$g"
done