|
| 1 | +name: Test and Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + master |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Test GFMRUN |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout Code |
| 17 | + uses: actions/checkout@v1 |
| 18 | + with: |
| 19 | + ref: ${{ github.ref }} |
| 20 | + |
| 21 | + - name: Set up Go |
| 22 | + uses: actions/setup-go@v1 |
| 23 | + with: |
| 24 | + go-version: 1.13 |
| 25 | + |
| 26 | + - name: Set GOPATH and PATH |
| 27 | + run: | |
| 28 | + echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)" |
| 29 | + echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin" |
| 30 | + shell: bash |
| 31 | + |
| 32 | + - name: Run Linter |
| 33 | + run: | |
| 34 | + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest |
| 35 | + golangci-lint run |
| 36 | +
|
| 37 | + - name: Run Test Suite |
| 38 | + uses: actions/setup-python@v1 |
| 39 | + with: |
| 40 | + python-version: '3.x' |
| 41 | + run: make all |
| 42 | + |
| 43 | + - name: Build Binary |
| 44 | + if: success() && contains(github.ref, 'v') |
| 45 | + run: make build |
| 46 | + |
| 47 | + - name: Create Release |
| 48 | + id: create_release |
| 49 | + if: success() && contains(github.ref, 'v') |
| 50 | + uses: actions/create-release@v1 |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + with: |
| 54 | + tag_name: ${{ github.ref }} |
| 55 | + release_name: Release ${{ github.ref }} |
| 56 | + draft: false |
| 57 | + prerelease: false |
| 58 | + |
| 59 | + - name: Extract Version |
| 60 | + if: success() && contains(github.ref, 'v') |
| 61 | + id: extract_version |
| 62 | + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} |
| 63 | + |
| 64 | + - name: Upload Linux Asset to Release |
| 65 | + if: success() && contains(github.ref, 'v') |
| 66 | + uses: actions/upload-release-asset@v1.0.1 |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + with: |
| 70 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 71 | + asset_path: ./gfmrun-linux-amd64-${{ steps.extract_version.outputs.VERSION }} |
| 72 | + asset_name: gfmrun-linux-amd64-${{ steps.extract_version.outputs.VERSION }} |
| 73 | + asset_content_type: application/octet-stream |
| 74 | + |
| 75 | + - name: Upload MacOS Asset to Release |
| 76 | + if: success() && contains(github.ref, 'v') |
| 77 | + uses: actions/upload-release-asset@v1.0.1 |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + with: |
| 81 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 82 | + asset_path: ./gfmrun-darwin-amd64-${{ steps.extract_version.outputs.VERSION }} |
| 83 | + asset_name: gfmrun-darwin-amd64-${{ steps.extract_version.outputs.VERSION }} |
| 84 | + asset_content_type: application/octet-stream |
| 85 | + |
| 86 | + - name: Upload Windows Asset to Release |
| 87 | + if: success() && contains(github.ref, 'v') |
| 88 | + uses: actions/upload-release-asset@v1.0.1 |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + with: |
| 92 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 93 | + asset_path: ./gfmrun-windows-amd64-${{ steps.extract_version.outputs.VERSION }}.exe |
| 94 | + asset_name: gfmrun-windows-amd64-${{ steps.extract_version.outputs.VERSION }}.exe |
| 95 | + asset_content_type: application/octet-stream |
0 commit comments