1
+ name : Release
2
+ on :
3
+ push :
4
+ tags :
5
+ - ' v*'
6
+ workflow_dispatch :
7
+ inputs :
8
+ revision :
9
+ description : ' Tag or revision to build binaries for'
10
+ type : string
11
+ required : true
12
+ create_release :
13
+ description : ' Should publish the binary or not'
14
+ required : true
15
+ default : ' false'
16
+
17
+ jobs :
18
+ build-and-upload-artifacts :
19
+ name : ' Build and upload artifacts'
20
+ strategy :
21
+ matrix :
22
+ platform : ['ubuntu-20.04', 'macos-12', 'windows-2022']
23
+ config : ['dev', 'release']
24
+ runs-on : ${{ matrix.platform }}
25
+ env :
26
+ TAG : ${{ github.event.ref }}
27
+ steps :
28
+ - uses : actions/checkout@v3
29
+ - name : ' 🐍 Install Bazelisk'
30
+ run : |
31
+ if [ "$RUNNER_OS" == "Windows" ]; then
32
+ choco install bazelisk
33
+ else
34
+ sudo npm install -g @bazel/bazelisk
35
+ fi
36
+ - id : auth
37
+ name : ' 🔓 Authenticate to Google Cloud'
38
+ uses : ' google-github-actions/auth@v1'
39
+ with :
40
+ workload_identity_provider : ${{ secrets.GCP_IDENTITY_PROVIDER }}
41
+ service_account : ${{ secrets.GCP_SERVICE_ACCOUNT }}
42
+ create_credentials_file : true
43
+ - name : ' 🚧 Build scip-clang'
44
+ run : |
45
+ echo "build --remote_cache=$CI_BAZEL_REMOTE_CACHE --google_default_credentials" > ci.bazelrc
46
+ bazel build //indexer:scip-clang --config="$CONFIG" --execution_log_binary_file=log
47
+ env :
48
+ CONFIG : ${{ matrix.config }}
49
+ CI_BAZEL_REMOTE_CACHE : ' https://storage.googleapis.com/sourcegraph_bazel_cache'
50
+ - name : ' 🔎 Identify OS'
51
+ run : echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
52
+ - name : ' 🪵 Upload log'
53
+ uses : actions/upload-artifact@v3
54
+ with :
55
+ name : ${{ env.OS }}-${{ matrix.config }}-build-log
56
+ path : log
57
+ - name : ${{ format('🪄 Rename binary ({0})', matrix.config) }}
58
+ run : |
59
+ SUFFIX="-dev"
60
+ if [ "$CONFIG" == "release" ]; then
61
+ SUFFIX=""
62
+ fi
63
+ outBinaryPath="scip-clang${SUFFIX}-$(uname -m)-$OS"
64
+ cp bazel-bin/main/scip-ruby "$outBinaryPath"
65
+ echo "outBinaryPath=$outBinaryPath" >> "$GITHUB_ENV"
66
+ echo "suffix=$SUFFIX" >> "$GITHUB_ENV"
67
+ env :
68
+ OS : ${{ env.OS }}
69
+ CONFIG : ${{ matrix.config }}
70
+ - name : ${{ format('📦 Store binary ({0})', matrix.config) }}
71
+ uses : actions/upload-artifact@v3
72
+ with :
73
+ name : ${{ matrix.platform }}-${{ matrix.config }}-release-artifacts
74
+ path : ${{ env.outBinaryPath }}
75
+
76
+ create-release :
77
+ name : ' Create release'
78
+ if : github.event_name != 'workflow_dispatch' || inputs.create_release
79
+ needs : build-and-upload-artifacts
80
+ runs-on : ' ubuntu-20.04'
81
+ steps :
82
+ - uses : actions/checkout@v3
83
+ - name : ' 📝 Create Release'
84
+ run : |
85
+ REV="$INPUT_REVISION"
86
+ if [ "$TRIGGER" != "workflow_dispatch" ]; then
87
+ REV="${GITHUB_REF/refs\/tags\//}"
88
+ fi
89
+ TEMPLATE="$(< .github/workflows/release-template.md)"
90
+ echo "${TEMPLATE//TAG_PLACEHOLDER/$TAG}" > notes
91
+ gh release create "$REV" --title "scip-clang $REV" --notes-file notes
92
+ env :
93
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
94
+ TRIGGER : ${{ github.event_name }}
95
+ INPUT_REVISION : ${{ inputs.revision }}
96
+ # Download everything to avoid spelling out the different
97
+ # platforms here.
98
+ - name : ' 📥 Download all artifacts'
99
+ uses : actions/download-artifact@v3
100
+ - name : ' 📤 Upload artifacts for release'
101
+ run : gh release upload "${GITHUB_REF/refs\/tags\//}" ./*-release-artifacts/*
102
+ env :
103
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments