Skip to content

Merge pull request #677 from cybozu-go/bump-1.26.4 #71

Merge pull request #677 from cybozu-go/bump-1.26.4

Merge pull request #677 from cybozu-go/bump-1.26.4 #71

Workflow file for this run

name: release
on:
push:
tags:
- 'v*'
env:
tag: ${GITHUB_REF#refs/tags/v}
prerelease: ${{ contains(github.ref, '-') }}
jobs:
sonobuoy:
name: Run sonobuoy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.NECO_TEST_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@v1
- name: Set GCP instance name
run: echo "INSTANCE_NAME=cke-${{ matrix.suite }}-${{ github.run_number }}-$(TZ=Asia/Tokyo date +%H%M%S)" >> $GITHUB_ENV
- name: Run sonobuoy
run: |
if [ ${{ github.event_name }} = "pull_request" ]; then
GITHUB_SHA=$(cat ${GITHUB_EVENT_PATH} | jq -r '.pull_request.head.sha')
fi
./bin/run-sonobuoy.sh
timeout-minutes: 240
- name: Check failures
run: |
grep -F 'no tests failed for plugin "e2e" in tarball' /tmp/e2e-check.log
- name: Upload sonobuoy test result
uses: actions/upload-artifact@v3
with:
name: sonobuoy-test
path: /tmp/sonobuoy.tar.gz
retention-days: 1
release-cke-image:
name: Release CKE Image
needs: sonobuoy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- run: make install GOBIN=$(pwd)/docker
- run: docker build -t quay.io/cybozu/cke:latest ./docker
- name: Push docker image to Quay.io
run: |
echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USER }} --password-stdin quay.io
echo "pushing CKE image ..."
docker tag quay.io/cybozu/cke:latest quay.io/cybozu/cke:${{ env.tag }}
docker push quay.io/cybozu/cke:${{ env.tag }}
if ${{ env.prerelease }} ; then
echo ===== Skip pushing branch tags for pre-release ${{ env.tag }} =====
exit 0
fi
BRANCH=$(echo ${{ env.tag }} | cut -d "." -f 1-2)
docker tag quay.io/cybozu/cke:latest quay.io/cybozu/cke:$BRANCH
docker push quay.io/cybozu/cke:$BRANCH
release-github:
name: Release on GitHub
runs-on: ubuntu-22.04
container:
image: quay.io/cybozu/golang:1.20-jammy
needs: release-cke-image
steps:
- uses: actions/checkout@v3
- name: Download sonobuoy test
uses: actions/download-artifact@v3
with:
name: sonobuoy-test
- name: Prepare files
run: |
mkdir /tmp/upload
cp ./sonobuoy.tar.gz /tmp/upload
tar xzf ./sonobuoy.tar.gz -C /tmp/upload --strip-components=4 plugins/e2e/results/global/e2e.log plugins/e2e/results/global/junit_01.xml
sed "s/vX\.Y\.Z/v${{ env.tag }}/" sonobuoy/README.md > /tmp/upload/README.md
sed "s/vX\.Y\.Z/v${{ env.tag }}/" sonobuoy/PRODUCT.yaml > /tmp/upload/PRODUCT.yaml
GOBIN=/tmp/upload CGO_ENABLED=0 go install -buildvcs=false ./pkg/cke ./pkg/ckecli
- name: Create release
run: |
OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)
REPOSITORY=$(echo ${{ github.repository }} | cut -d '/' -f 2)
if ${{ env.prerelease }}; then
PRERELEASE="-prerelease"
fi
ghr -t ${{ secrets.GITHUB_TOKEN }} -u ${OWNER} -r ${REPOSITORY} -n v${{ env.tag }} ${PRERELEASE} -b "See [CHANGELOG.md](./CHANGELOG.md) for details." v${{ env.tag }} /tmp/upload/