Merge pull request #699 from mackerelio/go124 #772
This file contains hidden or 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
| name: Build | |
| permissions: | |
| contents: write | |
| id-token: write | |
| packages: write | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - v* | |
| pull_request: | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| jobs: | |
| lint: | |
| uses: mackerelio/workflows/.github/workflows/go-lint.yml@v1.4.0 | |
| test: | |
| uses: mackerelio/workflows/.github/workflows/go-test.yml@v1.4.0 | |
| build: | |
| needs: [lint, test] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| rpm devscripts debhelper fakeroot \ | |
| crossbuild-essential-arm64 crossbuild-essential-armhf build-essential | |
| mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.24.x | |
| cache: true | |
| - run: make all | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build-artifacts | |
| path: | | |
| ~/rpmbuild/RPMS/*/*.rpm | |
| packaging/*.deb | |
| snapshot/*.zip | |
| snapshot/*.tar.gz | |
| build/*.tar.gz | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-build-artifacts | |
| path: artifacts/ | |
| - uses: mackerelio/staging-release-update-action@main | |
| if: github.ref == 'refs/heads/master' | |
| with: | |
| directory: artifacts/ | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| tag: staging | |
| - uses: mackerelio/create-release-action@main | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| with: | |
| directory: artifacts/ | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| tag-prefix: "refs/tags/v" | |
| bump-up-branch-prefix: "bump-version-" | |
| - name: update homebrew-mackerel-agent | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.MACKERELBOT_GITHUB_TOKEN }} | |
| event-type: release | |
| client-payload: '{"product": "mkr"}' | |
| repository: mackerelio/homebrew-mackerel-agent | |
| - uses: 8398a7/action-slack@v3 | |
| with: | |
| status: ${{ job.status }} | |
| fields: repo,message,commit,action,eventName,ref,workflow,job,took | |
| username: mkr-release | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.MACKEREL_SLACK_WEBHOOK_URL }} | |
| build_images_and_push: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.ROLE_TO_ASSUME }} | |
| role-session-name: "mkr-${{ github.run_id }}-${{ github.run_number }}" | |
| aws-region: ap-northeast-1 | |
| - name: Login to Public ECR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: public.ecr.aws | |
| env: | |
| AWS_REGION: us-east-1 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get tag | |
| id: get_tag | |
| run: echo "::set-output name=tag::${GITHUB_REF##*/}" | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: | | |
| linux/amd64 | |
| linux/arm64 | |
| push: true | |
| tags: | | |
| mackerel/mkr:latest | |
| mackerel/mkr:${{ steps.get_tag.outputs.tag }} | |
| public.ecr.aws/mackerel/mkr:latest | |
| public.ecr.aws/mackerel/mkr:${{ steps.get_tag.outputs.tag }} | |
| ghcr.io/${{ github.repository_owner }}/mkr:latest | |
| ghcr.io/${{ github.repository_owner }}/mkr:${{ steps.get_tag.outputs.tag }} |