-
Notifications
You must be signed in to change notification settings - Fork 65
97 lines (82 loc) · 3.43 KB
/
release.yaml
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
on:
release:
types: [published]
name: Publish Bundle
jobs:
build:
name: Publish Bundle
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Get Release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
- name: Generate Bundle
run: |
git submodule init
git submodule update
podman build -t common-templates-ci ./builder/
podman run \
-v "$(pwd)":/common-templates \
common-templates-ci \
/bin/bash -c "cd /common-templates && export REVISION=1 VERSION="${{ steps.get_release.outputs.tag_name }}" && make release"
- name: Upload Release Asset
id: upload-bundle-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./dist/common-templates.yaml
asset_name: common-templates.yaml
asset_content_type: text/plain
- name: Install golang
uses: actions/setup-go@v2
- name: Update SSP Operator
run: |
# Define vars
export VERSION="${{ steps.get_release.outputs.tag_name }}"
export SRC_TEMPLATES_FILE=common-templates.yaml
export DST_TEMPLATES_FILE=common-templates-${VERSION}.yaml
# If GITHUB_FORK_USER is changed, a new access token should be set as a repo secret (ACTIONS_TOKEN)
export GITHUB_FORK_USER=ksimon1
# Set git configs to sign the commit
git config --global user.email "[email protected]"
git config --global user.name "Common-templates Release Automation"
# Clone the operator repo with a token to allow pushing before creating a PR
git clone https://${GITHUB_FORK_USER}:${{ secrets.ACTIONS_TOKEN }}@github.com/${GITHUB_FORK_USER}/ssp-operator
# Authenticate with gh cli
echo ${{ secrets.ACTIONS_TOKEN }} > token.txt
gh auth login --with-token < token.txt
rm token.txt
cd ssp-operator
git remote add upstream https://github.com/kubevirt/ssp-operator
git fetch upstream
git checkout main
git rebase upstream/main
git checkout -b update-common-templates-${VERSION}
# Update the new common-templates file
cp ../dist/${SRC_TEMPLATES_FILE} data/common-templates-bundle/${DST_TEMPLATES_FILE}
sed -i "s/\bVersion\s*=.*/Version = \"${VERSION}\"/g" internal/operands/common-templates/version.go
go fmt ./...
# Commit and push the changes to the update branch
git add data internal
git commit -sm "Update common-templates bundle to version ${VERSION}"
git push --set-upstream origin update-common-templates-${VERSION}
# Create a new PR in the operator repo
gh pr create --repo kubevirt/ssp-operator \
--base main \
--head ${GITHUB_FORK_USER}:update-common-templates-${VERSION} \
--title "Update common-templates to ${VERSION}" \
--body "$(cat << EOF
Update common-templates bundle to ${VERSION}
**Release note**:
\`\`\`release-note
Update common-templates bundle to ${VERSION}
\`\`\`
EOF
)
"