| 1 | --- |
| 2 | name: Release binaries |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - 'v*' |
| 7 | |
| 8 | jobs: |
| 9 | linux_release: |
| 10 | name: Release linux binaries |
| 11 | runs-on: ubuntu-latest |
| 12 | strategy: |
| 13 | matrix: |
| 14 | goarch: [amd64, arm, arm64, mips64le, ppc64le, riscv64, s390x] |
| 15 | steps: |
| 16 | - name: Checkout code |
| 17 | uses: actions/checkout@v4 |
| 18 | |
| 19 | - name: Install Go |
| 20 | uses: actions/setup-go@v5 |
| 21 | with: |
| 22 | go-version-file: .github/go-version |
| 23 | |
| 24 | - name: Build |
| 25 | env: |
| 26 | GOARCH: ${{ matrix.goarch }} |
| 27 | CGO_ENABLED: 0 |
| 28 | run: ./build_linux.sh -ldflags '-extldflags -static -X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${{ github.ref_name }}' |
| 29 | |
| 30 | - name: COPY files |
| 31 | run: cp README.md LICENSE bin/ |
| 32 | |
| 33 | - name: Change plugin file ownership |
| 34 | working-directory: ./bin |
| 35 | run: sudo chown -R root:root . |
| 36 | |
| 37 | - name: Create dist directory |
| 38 | run: mkdir dist |
| 39 | |
| 40 | - name: Create archive file |
| 41 | working-directory: ./bin |
| 42 | run: tar cfzpv ../dist/cni-plugins-linux-${{ matrix.goarch }}-${{ github.ref_name }}.tgz . |
| 43 | |
| 44 | - name: Create sha256 checksum |
| 45 | working-directory: ./dist |
| 46 | run: sha256sum cni-plugins-linux-${{ matrix.goarch }}-${{ github.ref_name }}.tgz | tee cni-plugins-linux-${{ matrix.goarch }}-${{ github.ref_name }}.tgz.sha256 |
| 47 | |
| 48 | - name: Create sha512 checksum |
| 49 | working-directory: ./dist |
| 50 | run: sha512sum cni-plugins-linux-${{ matrix.goarch }}-${{ github.ref_name }}.tgz | tee cni-plugins-linux-${{ matrix.goarch }}-${{ github.ref_name }}.tgz.sha512 |
| 51 | |
| 52 | - name: Upload binaries to release |
| 53 | uses: svenstaro/upload-release-action@v2 |
| 54 | with: |
| 55 | repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 56 | file: ./dist/* |
| 57 | tag: ${{ github.ref }} |
| 58 | overwrite: true |
| 59 | file_glob: true |
| 60 | |
| 61 | windows_releases: |
| 62 | name: Release windows binaries |
| 63 | runs-on: ubuntu-latest |
| 64 | strategy: |
| 65 | matrix: |
| 66 | goarch: [amd64] |
| 67 | steps: |
| 68 | - name: Install dos2unix |
| 69 | run: sudo apt-get install dos2unix |
| 70 | |
| 71 | - name: Checkout code |
| 72 | uses: actions/checkout@v4 |
| 73 | |
| 74 | - name: Install Go |
| 75 | uses: actions/setup-go@v5 |
| 76 | with: |
| 77 | go-version-file: .github/go-version |
| 78 | |
| 79 | - name: Build |
| 80 | env: |
| 81 | GOARCH: ${{ matrix.goarch }} |
| 82 | CGO_ENABLED: 0 |
| 83 | run: ./build_windows.sh -ldflags '-extldflags -static -X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${{ github.ref_name }}' |
| 84 | |
| 85 | - name: COPY files |
| 86 | run: cp README.md LICENSE bin/ |
| 87 | |
| 88 | - name: Change plugin file ownership |
| 89 | working-directory: ./bin |
| 90 | run: sudo chown -R root:root . |
| 91 | |
| 92 | - name: Create dist directory |
| 93 | run: mkdir dist |
| 94 | |
| 95 | - name: Create archive file |
| 96 | working-directory: ./bin |
| 97 | run: tar cpfzv ../dist/cni-plugins-windows-${{ matrix.goarch }}-${{ github.ref_name }}.tgz . |
| 98 | |
| 99 | - name: Create sha256 checksum |
| 100 | working-directory: ./dist |
| 101 | run: sha256sum cni-plugins-windows-${{ matrix.goarch }}-${{ github.ref_name }}.tgz | tee cni-plugins-windows-${{ matrix.goarch }}-${{ github.ref_name }}.tgz.sha256 |
| 102 | |
| 103 | - name: Create sha512 checksum |
| 104 | working-directory: ./dist |
| 105 | run: sha512sum cni-plugins-windows-${{ matrix.goarch }}-${{ github.ref_name }}.tgz | tee cni-plugins-windows-${{ matrix.goarch }}-${{ github.ref_name }}.tgz.sha512 |
| 106 | |
| 107 | - name: Upload binaries to release |
| 108 | uses: svenstaro/upload-release-action@v2 |
| 109 | with: |
| 110 | repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 111 | file: ./dist/* |
| 112 | tag: ${{ github.ref }} |
| 113 | overwrite: true |
| 114 | file_glob: true |