ci:触发构建 #278
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright 2021 The Dapr Authors | |
# 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: dapr | |
on: | |
schedule: | |
- cron: '00 22 * * *' | |
push: | |
branches: | |
- master | |
- release-* | |
- feature/* | |
tags: | |
- v* | |
- x* | |
pull_request: | |
branches: | |
- master | |
- release-* | |
- feature/* | |
jobs: | |
build: | |
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries | |
runs-on: ${{ matrix.os }} | |
env: | |
GOVER: 1.19 | |
GOLANGCILINT_VER: v1.48.0 | |
PROTOC_VERSION: "21.1" | |
GOOS: ${{ matrix.target_os }} | |
GOARCH: ${{ matrix.target_arch }} | |
GOPROXY: https://proxy.golang.org | |
ARCHIVE_OUTDIR: dist/archives | |
TEST_OUTPUT_FILE_PREFIX: test_report | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-2019, macOS-latest] | |
target_arch: [arm, arm64, amd64] | |
include: | |
- os: ubuntu-latest | |
target_os: linux | |
- os: windows-2019 | |
target_os: windows | |
- os: macOS-latest | |
target_os: darwin | |
exclude: | |
- os: windows-2019 | |
target_arch: arm | |
- os: windows-2019 | |
target_arch: arm64 | |
- os: macOS-latest | |
target_arch: arm | |
steps: | |
- name: Set up Go ${{ env.GOVER }} | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GOVER }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
if: matrix.target_os == 'linux' && github.event_name != 'pull_request' | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
if: matrix.target_os == 'linux' && github.event_name != 'pull_request' | |
with: | |
version: v0.10.1 # Don't use latest since it broke our workflow once | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Parse release version and set REL_VERSION | |
run: python ./.github/scripts/get_release_version.py ${{ github.event_name }} | |
- name: Check white space in .md files | |
if: matrix.target_os == 'linux' && github.event_name == 'pull_request' | |
run: | | |
TRAILING_WHITESPACE=0 | |
# only check changed docs in pr | |
for file in $(git diff --cached --name-only --diff-filter=ACRMTU $GITHUB_BASE_REF | grep "\.md"); do | |
if grep -r '[[:blank:]]$' "$1" > /dev/null; then | |
echo "trailing whitespace: ${1}" >&2 | |
ERRORS=yes | |
((TRAILING_WHITESPACE=TRAILING_WHITESPACE+1)) | |
fi | |
done | |
if [[ -n "$ERRORS" ]]; then | |
echo >&2 | |
echo "ERRORS found" >&2 | |
echo "${TRAILING_WHITESPACE} files with trailing whitespace" >&2 | |
echo >&2 | |
exit 1 | |
fi | |
- name: Run go mod tidy check diff | |
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux' | |
run: make modtidy check-diff | |
- name: Run gen-proto check diff | |
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux' | |
run: | | |
wget https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.PROTOC_VERSION }}/protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip | |
unzip protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip -d protoc | |
sudo cp -r protoc/include/google/ /usr/local/include/ | |
sudo chmod -R 755 /usr/local/include/google | |
sudo cp protoc/bin/protoc /usr/local/bin/ | |
sudo chmod +x /usr/local/bin/protoc | |
rm -r protoc protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip | |
make init-proto | |
make gen-proto check-proto-diff | |
- name: Run make release to build and archive binaries | |
env: | |
GOOS: ${{ matrix.target_os }} | |
GOARCH: ${{ matrix.target_arch }} | |
ARCHIVE_OUT_DIR: ${{ env.ARCHIVE_OUTDIR }} | |
run: | | |
mkdir -p "${ARCHIVE_OUT_DIR}" | |
make release | |
shell: bash | |
- name: upload artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: dapr_${{ matrix.target_os }}_${{ matrix.target_arch }} | |
path: ${{ env.ARCHIVE_OUTDIR }} | |
- name: upload artifacts - grafana dashboards | |
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux' | |
uses: actions/upload-artifact@master | |
with: | |
name: dapr_grafana_dashboards | |
path: ./grafana/*.json | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-southeast-1 | |
- name: Login to Amazon ECR | |
if: matrix.target_os != 'darwin' && github.event_name != 'pull_request' | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build and push docker images to GitHub container registry | |
if: matrix.target_os != 'darwin' && github.event_name != 'pull_request' | |
run: | | |
echo "Build docker image and push image..." | |
make docker-push TARGET_OS=${{ matrix.target_os }} TARGET_ARCH=${{ matrix.target_arch }} DAPR_REGISTRY=798321202204.dkr.ecr.ap-southeast-1.amazonaws.com DAPR_TAG=${{ github.sha }} |