github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/.github/workflows/go.yml (about) 1 name: Go 2 3 on: 4 push: 5 branches: [ '*' ] 6 tags: [ '*.*.*', '*.*.*-*', 'test-release-*' ] 7 pull_request: 8 branches: [ 'main', 'v*.*.*' ] 9 10 env: 11 CDT_VAULT_SECRET: very_secret 12 13 jobs: 14 build: 15 runs-on: ${{ matrix.os }} 16 outputs: 17 sha_short: ${{steps.vars.outputs.sha_short}} 18 arch: ${{steps.vars.outputs.arch}} 19 os: ${{steps.vars.outputs.os}} 20 strategy: 21 matrix: 22 arch: [amd64] 23 cgo: [0] 24 os: [windows-latest, ubuntu-latest ] 25 include: 26 - os: macos-latest 27 arch: arm64 28 cgo: 1 29 - os: macos-latest 30 arch: amd64 31 cgo: 1 32 33 steps: 34 - uses: actions/checkout@v3 35 36 - name: Set up Go 37 uses: actions/setup-go@v3 38 with: 39 go-version: 1.17 40 41 - name: Set up Node 42 uses: actions/setup-node@v3 43 with: 44 node-version: '16' 45 cache: 'npm' 46 cache-dependency-path: gh-pages/package-lock.json 47 48 - name: generate vars 49 id: vars 50 run: | 51 echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" 52 echo "::set-output name=arch::${{matrix.arch}}" 53 echo "::set-output name=os::$(go run test/get-os.go)" 54 echo "::set-output name=ext::$(go run test/get-os.go extension)" 55 56 - name: Build 57 env: 58 GOARCH: ${{matrix.arch}} 59 CGO_ENABLED: ${{matrix.cgo}} 60 run: | 61 go build -o build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} -ldflags='-X main.version=${{github.ref_name}} -X main.buildNum=${{github.run_number}} -X main.appName=cdt' 62 63 go build -o build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} -ldflags="-X main.version=${{github.ref_name}} -X main.buildNum=${{github.run_number}} -X main.appName=cola -X 'main.appLongName=Command Launcher'" 64 65 - name: Test & Benchmark 66 run: go test -v ./... 67 68 - name: Integration-test 69 run: | 70 echo "${{github.workspace}}/test" 71 SCRIPT_DIR='${{github.workspace}}/test' test/integration.sh 72 shell: bash 73 74 - name: documentation lint 75 run: cd gh-pages && npm install && npm run test 76 77 - name: Upload CDT 78 uses: actions/upload-artifact@v3 79 with: 80 name: ${{steps.vars.outputs.os}}-${{matrix.arch}} 81 path: build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} 82 83 - name: Upload COLA 84 uses: actions/upload-artifact@v3 85 with: 86 name: ${{steps.vars.outputs.os}}-${{matrix.arch}} 87 path: build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} 88 89 - name: Rename binary name for release 90 if: startsWith(github.ref, 'refs/tags/') 91 run: | 92 mv build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}} 93 mv build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{steps.vars.outputs.sha_short}} build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}} 94 95 - name: Release 96 uses: softprops/action-gh-release@v1 97 if: startsWith(github.ref, 'refs/tags/') 98 with: 99 files: | 100 build/cdt_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}} 101 build/cola_${{steps.vars.outputs.os}}_${{matrix.arch}}_${{github.ref_name}}${{steps.vars.outputs.ext}} 102 103 packaging: 104 needs: [ build ] 105 runs-on: ubuntu-latest 106 steps: 107 - name: Download linux amd64 artifact 108 uses: actions/download-artifact@v3 109 with: 110 name: linux-amd64 111 path: output/linux/amd64/ 112 - name: Download windows amd64 artifact 113 uses: actions/download-artifact@v3 114 with: 115 name: windows-amd64 116 path: output/windows/amd64/ 117 - name: Download darwin amd64 artifact 118 uses: actions/download-artifact@v3 119 with: 120 name: darwin-amd64 121 path: output/darwin/amd64/ 122 - name: Download darwin-arm64 artifact 123 uses: actions/download-artifact@v3 124 with: 125 name: darwin-arm64 126 path: output/darwin/arm64/ 127 128 - name: Rename binary name 129 run: | 130 mv output/darwin/arm64/cdt_darwin_arm64_${{needs.build.outputs.sha_short}} output/darwin/arm64/cdt 131 mv output/darwin/amd64/cdt_darwin_amd64_${{needs.build.outputs.sha_short}} output/darwin/amd64/cdt 132 mv output/linux/amd64/cdt_linux_amd64_${{needs.build.outputs.sha_short}} output/linux/amd64/cdt 133 mv output/windows/amd64/cdt_windows_amd64_${{needs.build.outputs.sha_short}} output/windows/amd64/cdt.exe 134 135 - name: Zip the package 136 uses: thedoctor0/zip-release@master 137 if: startsWith(github.ref, 'refs/tags/') 138 with: 139 type: 'zip' 140 filename: cdt_${{github.ref_name}}.zip 141 directory: output 142 143 - name: Upload 144 uses: actions/upload-artifact@v3 145 if: startsWith(github.ref, 'refs/tags/') 146 with: 147 name: all-in-one.zip 148 path: output/cdt_${{github.ref_name}}.zip 149 150 - name: Display structure of downloaded files 151 run: ls -R 152 working-directory: output 153 154 - name: Release 155 uses: softprops/action-gh-release@v1 156 if: startsWith(github.ref, 'refs/tags/') 157 with: 158 files: output/cdt_${{github.ref_name}}.zip 159 160 161 update-latest-version: 162 needs: [ packaging ] 163 runs-on: ubuntu-latest 164 steps: 165 - uses: actions/checkout@v3 166 167 - name: Generate latest version file 168 run: | 169 mkdir output 170 cat release-notes.yaml | yq -r '."${{github.ref_name}}"' > output/latest.yaml 171 172 - name: Display latest version file content 173 run: cat output/latest.yaml 174 175 - name: Upload latest version index 176 uses: actions/upload-artifact@v3 177 with: 178 name: latest.yaml 179 path: output/latest.yaml 180 181 - name: Release & Update the version index 182 uses: softprops/action-gh-release@v1 183 if: startsWith(github.ref, 'refs/tags/') 184 with: 185 files: output/latest.yaml 186 187 188