-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (176 loc) · 6.35 KB
/
Hog-tag.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# Copyright 2018-2024 The University of Birmingham
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: Hog-tag
on:
workflow_call:
inputs:
HOG_CREATE_OFFICIAL_RELEASE:
required: false
type: boolean
HOG_OFFICIAL_BIN_EOS_PATH:
type: string
required: false
HOG_OFFICIAL_BIN_PATH:
type: string
required: false
HOG_USE_DOXYGEN:
required: false
type: boolean
secrets:
HOG_PUSH_TOKEN:
required: true
HOG_EMAIL:
required: true
HOG_USER:
required: true
EOS_PASSWORD:
required: false
EOS_USER:
required: false
EOS_MGM_URL:
required: false
env:
PR_NUMBER: ${{ github.event.number }}
HOG_PUSH_TOKEN: ${{ secrets.HOG_PUSH_TOKEN }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
HOG_USER: ${{ secrets.HOG_USER }}
HOG_EMAIL: ${{ secrets.HOG_EMAIL }}
HOG_PATH: ${{ secrets.HOG_PATH }}
EOS_USER: ${{ secrets.EOS_USER }}
EOS_PASSWORD: ${{ secrets.EOS_PASSWORD }}
GH_TOKEN: ${{ secrets.HOG_PUSH_TOKEN }}
jobs:
get_artifacts:
runs-on: ubuntu-latest
container: gitlab-registry.cern.ch/hog/hog-docker
steps:
- uses: actions/checkout@v4
name: Checkout Repository
with:
fetch-depth: 0
token: ${{secrets.HOG_PUSH_TOKEN}}
submodules: 'true'
- name: Get Artifacts
id: artifacts
shell: bash
run: |
git config --global user.email "$HOG_EMAIL"
git config --global user.name "$HOG_USER"
git fetch
git checkout $GITHUB_HEAD_REF
git submodule init
git submodule update
source ./Hog/Other/CommonFunctions.sh
git fetch origin refs/notes/*:refs/notes/*
note=(`git notes show`) || {
echo "No note found, probably you pushed to a branch that should protected (e.g. master, develop)";
exit 1;
}
runid=${note[0]}
tag=${note[2]}
echo "PR number $runid"
if [[ "${{ inputs.HOG_USE_DOXYGEN }}" == "1" ]]; then
dox_var="-doxygen"
fi
./Hog/Other/GetArtifactsAndRename.sh -mr ${runid} -github ${dox_var}
echo "tag=$new_tag" >> $GITHUB_OUTPUT
echo "runid=${note[0]}" >> $GITHUB_OUTPUT
- name: Archive Simulation Artifacts
uses: actions/upload-artifact@v4
with:
name: Archive-Artifacts
path: |
bin
Doc
archive_binary_files:
runs-on: self-hosted
if: ${{ inputs.HOG_OFFICIAL_BIN_EOS_PATH != '' || inputs.HOG_OFFICIAL_BIN_PATH != '' }}
needs: get_artifacts
steps:
- uses: actions/download-artifact@v4
name: Download Artifacts
- name: Archive
shell: bash
run: |
if [[ "${{ inputs.HOG_OFFICIAL_BIN_PATH}}" != "" ]]; then
BIN_PATH=${{ inputs.HOG_OFFICIAL_BIN_PATH}}
elif [[ "${{ inputs.HOG_OFFICIAL_BIN_EOS_PATH }}" != "" ]]; then
BIN_PATH=${{ inputs.HOG_OFFICIAL_BIN_EOS_PATH }}
echo "From version Hog2024.1, HOG_OFFICIAL_BIN_EOS_PATH variable will be deprecated. Please use HOG_OFFICIAL_BIN_PATH to define the path where to copy the official bitfiles."
fi
if [[ $BIN_PATH == /eos/* ]]; then
until echo $EOS_PASSWORD | kinit -V [email protected]; do
echo Retrying;
sleep 2;
done;
fi;
if [ -v "${{ secrets.EOS_MGM_URL}}" ]; then
export EOS_MGM_URL=${{ secrets.EOS_MGM_URL }}
else
export EOS_MGM_URL="root://eosuser.cern.ch"
fi;
echo "Copying Doxygen documentation to $BIN_PATH/Doc"
if [[ $BIN_PATH == /eos/* ]]; then
eos mkdir -p $BIN_PATH/Doc
xrdcp -rsf Archive-Artifacts/Doc/html/* ${EOS_MGM_URL}/$BIN_PATH/Doc
else
mkdir -p $BIN_PATH/Doc
cp -r Archive-Artifacts/Doc/html/* $BIN_PATH/Doc
fi;
echo "Copying binary files to $BIN_PATH/${tag}";
if [[ $BIN_PATH == /eos/* ]]; then
eos mkdir $BIN_PATH/${tag};
xrdcp -rfs Archive-Artifacts/bin/* ${EOS_MGM_URL}//$BIN_PATH/${tag};
else
mkdir $BIN_PATH/${tag};
cp -r Archive-Artifacts/bin/* $BIN_PATH/${tag};
fi;
create_github_release:
runs-on: ubuntu-latest
container: gitlab-registry.cern.ch/hog/hog-docker
if: ${{ inputs.HOG_CREATE_OFFICIAL_RELEASE }}
needs: get_artifacts
steps:
- uses: actions/checkout@v4
name: Checkout Repository
with:
fetch-depth: 0
token: ${{secrets.HOG_PUSH_TOKEN}}
submodules: 'true'
- uses: actions/download-artifact@v4
name: Download Artifacts
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body_path: Archive-Artifacts/bin/note.md
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
# This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./binaries.zip
asset_name: Binaries
asset_content_type: application/zip