forked from GoogleCloudPlatform/DataflowTemplates
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (112 loc) · 3.94 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
name: Release
on:
workflow_dispatch:
inputs:
candidateName:
description: 'Name of the candidate'
type: string
required: true
branchCommit:
description: 'Commit to check out. If it is the most recent commit then leave blank.'
type: string
required: false
default: ''
cherrypickCommits:
description: 'Comma separated commits to cherry pick'
type: string
required: false
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: [self-hosted, it]
steps:
- name: Get releaser identity
run: |
git config --global user.name '${{github.actor}}'
git config --global user.email '${{github.actor}}@users.noreply.github.com'
- name: Declare release branch name and tag name
id: variables
run: |
echo "releaseBranchName=release_${CANDIDATE_NAME,,}" >> $GITHUB_OUTPUT
echo "tagName=${CANDIDATE_NAME^^}" >> $GITHUB_OUTPUT
env:
CANDIDATE_NAME: ${{ inputs.candidateName }}
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Create release branch
run: git checkout -b $RELEASE_BRANCH_NAME $BRANCH_COMMIT
env:
RELEASE_BRANCH_NAME: ${{ steps.variables.outputs.releaseBranchName }}
BRANCH_COMMIT: ${{ inputs.branchCommit }}
- name: Cherry pick commits
run: |
commits=$(echo $CHERRYPICK_COMMITS | tr "," "\n")
for commit in $commits
do
echo "Cherry picking $commit."
git cherry-pick $commit
done
env:
CHERRYPICK_COMMITS: ${{ inputs.cherrypickCommits }}
- name: Add tag to most recent commit
run: |
DATE=$(date -d"next-monday - 1week" +'%Y-%m-%d')
T_COMMIT=$(git log -n 1 $RELEASE_BRANCH_NAME --pretty=format:'%H')
git tag -a $TAG_NAME -m "Release week of $DATE" $T_COMMIT
env:
RELEASE_BRANCH_NAME: ${{ steps.variables.outputs.releaseBranchName }}
TAG_NAME: ${{ steps.variables.outputs.tagName }}
- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env
- name: Run Build
run: ./cicd/run-build --changed-files="pom.xml"
- name: Run Unit Tests
run: ./cicd/run-unit-tests --changed-files="pom.xml"
- name: Run Integration Smoke Tests
run: |
./cicd/run-it-smoke-tests \
--changed-files="pom.xml" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
--it-release=true
- name: Run Integration Tests
run: |
./cicd/run-it-tests \
--changed-files="pom.xml" \
--it-region="us-central1" \
--it-project="cloud-teleport-testing" \
--it-artifact-bucket="cloud-teleport-testing-it-gitactions" \
--it-release=true
- name: Upload Tests Report
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always() # always run even if previous step fails
with:
name: surefire-test-results
path: '**/surefire-reports/TEST-*.xml'
retention-days: 1
- name: Create artifacts and push
run: |
mvn verify -PtemplatesRelease \
-DprojectId="dataflow-templates" \
-DbucketName="dataflow-templates-staging" \
-DlibrariesBucketName="dataflow-templates-libraries" \
-DstagePrefix="${CANDIDATE_NAME}" \
-Dmaven.test.skip -T8 -e
env:
CANDIDATE_NAME: ${{ inputs.candidateName }}
- name: Push tags
run: |
git push -u origin --tags
- name: Release
run: |
gh release create $TAG_NAME --title "Dataflow Templates $TAG_NAME" --notes ""
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.variables.outputs.tagName }}