container/docker: GetStats: prevent nil-pointer #5
Workflow file for this run
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: Release Binaries | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to build and publish' | |
| required: true | |
| type: string | |
| jobs: | |
| build-linux-binaries: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| arch: [amd64, arm64] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }} | |
| fetch-depth: 0 # Fetch all history for proper versioning | |
| - name: Set up Docker | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Set VERSION environment variable | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "VERSION=${{ inputs.tag }}" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| fi | |
| - name: Build Linux ${{ matrix.arch }} binary | |
| env: | |
| GOARCH: ${{ matrix.arch }} | |
| OUTPUT_NAME_WITH_ARCH: "true" | |
| VERSION: ${{ env.VERSION }} | |
| run: | | |
| # Create a Docker container with the appropriate architecture | |
| docker run --rm -v ${PWD}:/go/src/github.com/google/cadvisor \ | |
| --platform linux/${{ matrix.arch }} \ | |
| golang:1.25 \ | |
| /bin/bash -c "cd /go/src/github.com/google/cadvisor && GOARCH=${{ matrix.arch }} OUTPUT_NAME_WITH_ARCH=true VERSION=${{ env.VERSION }} GO_FLAGS='-buildvcs=false -tags=netgo' ./build/build.sh" | |
| - name: Generate SHA256 checksums | |
| run: | | |
| cd _output | |
| # List all files in the output directory | |
| ls -la | |
| # Generate SHA256 checksums for all binaries | |
| find . -name "cadvisor*" -type f -not -name "*.sha256" -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \; | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cadvisor-linux-${{ matrix.arch }} | |
| path: | | |
| _output/cadvisor* | |
| retention-days: 1 | |
| create-release: | |
| needs: build-linux-binaries | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Needed for creating GitHub releases | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }} | |
| - name: Set VERSION environment variable | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "VERSION=${{ inputs.tag }}" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| fi | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure of downloaded files | |
| run: ls -R artifacts | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.VERSION }} | |
| name: cAdvisor ${{ env.VERSION }} | |
| draft: false | |
| prerelease: ${{ contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta') || contains(env.VERSION, 'rc') }} | |
| generate_release_notes: true | |
| files: | | |
| artifacts/**/* |