|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + |
| 11 | + release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + - uses: actions/cache@v2 |
| 16 | + with: |
| 17 | + path: | |
| 18 | + ~/.cache/go-build |
| 19 | + ~/go/pkg/mod |
| 20 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 21 | + restore-keys: | |
| 22 | + ${{ runner.os }}-go- |
| 23 | + - name: Set up Go |
| 24 | + uses: actions/setup-go@v2 |
| 25 | + with: |
| 26 | + go-version: 1.16 |
| 27 | + |
| 28 | + - name: Build |
| 29 | + run: make build |
| 30 | + |
| 31 | + - name: Test |
| 32 | + run: go test -v ./... |
| 33 | + |
| 34 | + - name: Set up QEMU |
| 35 | + uses: docker/setup-qemu-action@v1 |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v1 |
| 38 | + - name: Login to DockerHub |
| 39 | + uses: docker/login-action@v1 |
| 40 | + with: |
| 41 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 42 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 43 | + |
| 44 | + - name: Get version |
| 45 | + id: get_version |
| 46 | + run: echo ::set-output name=VERSION::${GITHUB_REF:10} |
| 47 | + |
| 48 | + - name: Build and push |
| 49 | + id: docker_build |
| 50 | + uses: docker/build-push-action@v2 |
| 51 | + with: |
| 52 | + push: true |
| 53 | + tags: codfrm/cloudcat:${{ steps.get_version.outputs.VERSION }} |
| 54 | + |
| 55 | + - name: Create Release |
| 56 | + id: create_release |
| 57 | + uses: actions/create-release@latest |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + with: |
| 61 | + tag_name: ${{ github.ref }} |
| 62 | + release_name: scriptcat-${{ github.ref }} |
| 63 | + body: | |
| 64 | + 'no description' |
| 65 | + draft: false |
| 66 | + prerelease: false |
| 67 | + |
| 68 | + - name: Build Target |
| 69 | + run: | |
| 70 | + VERSION=${{ steps.get_version.outputs.VERSION }} GOOS=linux GOARCH=amd64 make target |
| 71 | + tar -zcvf cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64 |
| 72 | +
|
| 73 | + - name: Upload Release Asset zip |
| 74 | + uses: actions/upload-release-asset@v1 |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + with: |
| 78 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 79 | + asset_path: cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz |
| 80 | + asset_name: cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz |
| 81 | + asset_content_type: application/tar+gz |
0 commit comments