|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + # push: |
| 5 | + # branches: [ main ] |
| 6 | + # pull_request: |
| 7 | + # branches: [ main ] |
| 8 | + # release: |
| 9 | + # types: [published] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build and Test |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v3 |
| 19 | + |
| 20 | + - name: Set up Go |
| 21 | + uses: actions/setup-go@v3 |
| 22 | + with: |
| 23 | + go-version: 'stable' |
| 24 | + |
| 25 | + - name: Build and Test on Default Platform |
| 26 | + run: | |
| 27 | + go build -v ./... |
| 28 | + go test -v ./... |
| 29 | + |
| 30 | + - name: Delete Existing Release Assets |
| 31 | + run: | |
| 32 | + release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/memoryTest/releases/tags/output" | jq -r '.id') |
| 33 | + echo "Deleting existing release assets..." |
| 34 | + assets=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/oneclickvirt/memoryTest/releases/$release_id/assets" | jq -r '.[] | .id') |
| 35 | + for asset in $assets; do |
| 36 | + echo "Deleting asset with ID: $asset" |
| 37 | + curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/memoryTest/releases/assets/$asset" |
| 38 | + done |
| 39 | + sleep 60 |
| 40 | +
|
| 41 | + release-binary: |
| 42 | + name: Release Go Binary |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: build |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v3 |
| 48 | + |
| 49 | + - name: Set up Go |
| 50 | + uses: actions/setup-go@v3 |
| 51 | + with: |
| 52 | + go-version: 'stable' |
| 53 | + |
| 54 | + - name: Build and Release |
| 55 | + run: | |
| 56 | + mkdir -p bin |
| 57 | + cd cmd |
| 58 | + CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ../bin/memoryTest-${{ matrix.goos }}-${{ matrix.goarch }} -v -ldflags="-extldflags=-static" . |
| 59 | +
|
| 60 | + - name: Upload New Assets |
| 61 | + run: | |
| 62 | + release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/memoryTest/releases/tags/output" | jq -r '.id') |
| 63 | + echo "Uploading new assets to release..." |
| 64 | + for file in ./bin/*; do |
| 65 | + echo "Uploading $file to release..." |
| 66 | + curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
| 67 | + -H "Content-Type: application/octet-stream" \ |
| 68 | + --data-binary @"$file" \ |
| 69 | + "https://uploads.github.com/repos/oneclickvirt/memoryTest/releases/$release_id/assets?name=$(basename "$file")" |
| 70 | + rm -rf $file |
| 71 | + done |
| 72 | +
|
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + goos: [windows, freebsd, openbsd, linux, darwin] |
| 76 | + goarch: [amd64, 386] |
| 77 | + exclude: |
| 78 | + - goarch: 386 |
| 79 | + goos: darwin |
| 80 | + include: |
| 81 | + - goos: windows |
| 82 | + goarch: 386 |
| 83 | + - goos: windows |
| 84 | + goarch: amd64 |
| 85 | + - goos: windows |
| 86 | + goarch: arm64 |
| 87 | + - goos: windows |
| 88 | + goarch: arm |
| 89 | + goarm: 7 |
| 90 | + - goos: darwin |
| 91 | + goarch: arm64 |
| 92 | + - goos: linux |
| 93 | + goarch: arm |
| 94 | + goarm: 7 |
| 95 | + - goos: linux |
| 96 | + goarch: arm64 |
| 97 | + - goos: linux |
| 98 | + goarch: riscv64 |
| 99 | + - goos: linux |
| 100 | + goarch: mips64 |
| 101 | + - goos: linux |
| 102 | + goarch: mips64le |
| 103 | + - goos: linux |
| 104 | + goarch: mipsle |
| 105 | + - goos: linux |
| 106 | + goarch: mips |
| 107 | + - goos: linux |
| 108 | + goarch: ppc64 |
| 109 | + - goos: linux |
| 110 | + goarch: ppc64le |
| 111 | + - goos: freebsd |
| 112 | + goarch: arm64 |
| 113 | + - goos: freebsd |
| 114 | + goarch: arm |
| 115 | + goarm: 7 |
| 116 | + - goos: openbsd |
| 117 | + goarch: arm64 |
| 118 | + - goos: openbsd |
| 119 | + goarch: arm |
| 120 | + goarm: 7 |
| 121 | + # - goos: linux |
| 122 | + # goarch: mipsle |
| 123 | + # gomips: softfloat |
| 124 | + # - goos: linux |
| 125 | + # goarch: mips |
| 126 | + # gomips: softfloat |
| 127 | + # - goos: linux |
| 128 | + # goarch: arm |
| 129 | + # goarm: 6 |
| 130 | + # - goos: linux |
| 131 | + # goarch: arm |
| 132 | + # goarm: 5 |
0 commit comments