From 6cf4918113600d64ed7c623d52435d4921088e31 Mon Sep 17 00:00:00 2001 From: Timur Zununbekov Date: Tue, 20 Feb 2024 11:24:13 +0600 Subject: [PATCH] CI build and release updates --- .github/workflows/build-packages.yml | 60 ++++++++++++----- .github/workflows/release.yml | 90 +++++++++++++++++++++++++ .github/workflows/tests-and-linters.yml | 4 +- 3 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml index 5d98b4df33..de4ce367db 100644 --- a/.github/workflows/build-packages.yml +++ b/.github/workflows/build-packages.yml @@ -14,8 +14,42 @@ env: GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: + setup-env: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + + - name: Prepare environment + run: | + BUILD_TAG= + echo "BUILD_COMMIT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV + echo "BUILD_NUMBER=${{ github.repository}}-${{ github.workflow }}-${{ github.run_id }}-ghactions" >> $GITHUB_ENV + echo "BUILD_BRANCH=${{ github.ref }}" >> $GITHUB_ENV + echo "BUILD_BRANCH_SAFE=${{ github.ref }}" >> $GITHUB_ENV + echo "BUILD_TAG=${{ github.ref }}" >> $GITHUB_ENV + echo "RELEASE_BUILD + + + - name: Create bucket + run: | + go run mage.go -v MakeBucket + + - name: Generate Env + run: go run mage.go -v GenerateEnvFile + + - uses: actions/upload-artifact@v4 + with: + name: env.sh + path: build/env.sh + build-packages: runs-on: ubuntu-latest + needs: [setup-env] strategy: max-parallel: 4 @@ -36,11 +70,12 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21.x' - - name: Generate Env - run: go run mage.go -v GenerateEnvFile + - uses: actions/download-artifact@v4 + with: + name: env.sh - name: Setup FPM run: | @@ -52,24 +87,22 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - source build/env.sh - # Following line ensures that s3 bucket name won't overlap with the old CI's target - # Should be removed when the old CI is disabled - export BUILD_NUMBER=$BUILD_NUMBER"-ghactions" + source env.sh go run mage.go -v ${{ matrix.platform }} build-swagger: runs-on: ubuntu-latest - needs: [build-packages] + needs: [setup-env, build-packages] steps: - uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21.x' - - name: Generate Env - run: go run mage.go -v GenerateEnvFile + - uses: actions/download-artifact@v4 + with: + name: env.sh - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -83,8 +116,5 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - source build/env.sh - # Following line ensures that s3 bucket name won't overlap with the old CI's target - # Should be removed when the old CI is disabled - export BUILD_NUMBER=$BUILD_NUMBER"-ghactions" + source env.sh go run mage.go -v PackageDockerSwaggerRedoc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..8968e4adda --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,90 @@ +name: Release +on: + workflow_call: + # push: + # tags: + +jobs: + release-snapshot: + runs-on: ubuntu-latest + + strategy: + max-parallel: 3 + matrix: + platform: + - ReleaseGithubSnapshot + # master only + # - ReleaseGithubNightly + - ReleaseDockerSnapshot + - ReleaseDebianPPASnapshot + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + - uses: actions/download-artifact@v4 + with: + name: env.sh + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Release snapshot + run: | + source env.sh + go run mage.go -v ${{ matrix.platform }} + + # master only + # - name: Release Go report + # run: bin/release_goreport + + release-tag: + runs-on: ubuntu-latest + + strategy: + max-parallel: 4 + matrix: + platform: + - ReleaseGithubTag + - ReleaseDockerTag + - ReleaseDebianPPAPreRelease + - ReleaseAndroidSDK + - ReleaseAndroidProviderSDK + + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + - uses: actions/download-artifact@v4 + with: + name: env.sh + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Release tag + run: | + source build/env.sh + go run mage.go -v ${{ matrix.platform }} + + post-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + - name: Generate Env + run: go run mage.go -v GenerateEnvFile + - name: Remove bucket + run: go run mage.go -v RemoveBucket + # master only + # - name: Notify UptimeRobot + # run: | + # if [ "$NIGHTLY_BUILD" = "1" -o "$NIGHTLY_BUILD" = "T" -o "$NIGHTLY_BUILD" = "true" -o "$NIGHTLY_BUILD" = "True" -o "$NIGHTLY_BUILD" = "TRUE" ]; then + # curl -so /dev/null -I "$NIGHTLY_UPTIMEROBOT" + # fi + - name: PR Avado + run: go run mage.go -v CreateAvadoPR + diff --git a/.github/workflows/tests-and-linters.yml b/.github/workflows/tests-and-linters.yml index b3ff7ad3a7..30b1033992 100644 --- a/.github/workflows/tests-and-linters.yml +++ b/.github/workflows/tests-and-linters.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21.x' @@ -38,7 +38,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21.x'