-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (125 loc) · 6.07 KB
/
prep-internal-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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Launched manually
on:
workflow_dispatch:
inputs:
prev_branch_name:
description: 'Prev branch name, must start with v'
required: true
default: 'v0.1.0-rc.1'
release_branch_name:
description: 'Release branch name, must start with v'
required: true
default: 'v0.1.0-rc.2'
jobs:
build:
name: Prep release
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Checkout the code
uses: actions/checkout@v2
- name: Check release version and set next version
run: |
if ! echo "${{ github.event.inputs.release_branch_name }}" | grep ^v ; then
echo "Incorrect release branch name ${{ github.event.inputs.release_branch_name }}, must start with 'v'" ; exit 1
fi
if echo "${{ github.ref_name }}" | grep ^dev ; then
# set next dev version GH env, otherwise set it empty
echo "NEXT_DEV_VERSION=$(echo ${{ github.ref_name }} | awk -F. -v OFS=. '{$NF += 1 ; print}')" >> $GITHUB_ENV
fi
- name: Code format, dependencies, checks
run: |
make fmt
make dep
make vet
- name: Check code builds and pass acceptance test
run: |
make install
make testacc
- name: Ensure all docs have been generated
run: make generate-docs
- name: Ensure version reflects release candidate version
run: |
VERSION=$(echo "${{ github.event.inputs.release_branch_name }}" | cut -d'v' -f2)
sed -i "s/version =.*$/version = \"${VERSION}\"/g" version.go
- name: Check changed files
uses: tj-actions/verify-changed-files@v17
id: check-changed-files
- name: Run step only when any of the files change
if: steps.check-changed-files.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.check-changed-files.outputs.changed_files }}"
- name: Commit back updates when any of the files change
if: steps.check-changed-files.outputs.files_changed == 'true'
uses: EndBug/add-and-commit@v9
with:
committer_name: GitHub Actions
committer_email: [email protected]
message: 'Updating release candidate [skip ci]'
new_branch: GeneratedSourceUpdates-${{ github.ref_name }}
- name: Create pull request if needed, then break here because manual approval of the changes is required
if: steps.check-changed-files.outputs.files_changed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT_BRANCH=${GITHUB_REF_NAME}
gh pr create -B ${CURRENT_BRANCH} -H "GeneratedSourceUpdates-${CURRENT_BRANCH}" --title "Merge generated source updates into release candidate ${CURRENT_BRANCH}" --body 'Created by Github action'
echo Review and approve PR before release can continue
exit 1 // force actions stop here
- name: Prep product release for Whitesource
run: |
VERSION=$(cat version.go | grep version | cut -d'=' -f2 | xargs)
sed -i "s/productVersion=.*$/productVersion=v${VERSION}/g" ci/whitesource/whitesource-agent.config
sed -i "s/productName=.*$/productName=${{ github.event.repository.name }}/g" ci/whitesource/whitesource-agent.config
sed -i "s/projectName=.*$/projectName=${{ github.event.repository.name }}/g" ci/whitesource/whitesource-agent.config
cat ci/whitesource/whitesource-agent.config | grep productVersion
curl https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar --output ci/whitesource/wss-unified-agent.jar
export WS_APIKEY="${{ secrets.WSS_API_KEY }}"
export WS_WSS_URL="https://saas.whitesourcesoftware.com/agent"
export WS_PRODUCTNAME="${{ github.event.repository.name }}"
export WS_PROJECTNAME="${{ github.event.repository.name }}"
java -jar ci/whitesource/wss-unified-agent.jar -c ci/whitesource/whitesource-agent.config -d .
- name: Create release branch starting point
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch
git push origin refs/remotes/origin/${{ github.event.inputs.prev_branch_name }}:refs/heads/${{ github.event.inputs.release_branch_name }}
- name: Create PR to release branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT_BRANCH=${GITHUB_REF_NAME}
gh pr create -B ${{ github.event.inputs.release_branch_name }} --title "New release ${{ github.event.inputs.release_branch_name }}" --body 'Created by Github action'
# - name: Create the release branch
# uses: peterjgrainger/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# branch: "${{ github.event.inputs.release_branch_name }}"
# - name: Create next dev branch
# if: env.NEXT_DEV_VERSION != ''
# uses: peterjgrainger/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# branch: ${{ env.NEXT_DEV_VERSION }}
# - name: Create next dev branch
# if: env.NEXT_DEV_VERSION != ''
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# git checkout -b ${{ env.NEXT_DEV_VERSION }}
# VERSION=$(echo "${{ env.NEXT_DEV_VERSION }}" | cut -d'v' -f2)
# sed -i "s/version =.*$/version = \"${VERSION}\"/g" version.go
# git commit -a -m "Uprev'd version to ${VERSION}"
# git push --set-upstream origin ${{ env.NEXT_DEV_VERSION }}
# - name: Delete last dev branch
# if: env.NEXT_DEV_VERSION != ''
# uses: dawidd6/action-delete-branch@v3
# with:
# github_token: ${{github.token}}
# branches: "${{ github.ref_name }}"