|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths-ignore: |
| 8 | + - 'README.md' |
| 9 | + - 'docs/**' |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v2 |
| 19 | + - name: Get next version |
| 20 | + id: version |
| 21 | + run: | |
| 22 | + curl -L https://github.com/idc101/git-mkver/releases/download/v$MKVER/git-mkver-darwin-amd64-$MKVER.tar.gz | tar xvz |
| 23 | + sudo mv git-mkver /usr/local/bin |
| 24 | + echo "::set-output name=version::$(git mkver next)" |
| 25 | + env: |
| 26 | + MKVER: "1.1.1" |
| 27 | + - name: Create changelog |
| 28 | + id: changelog |
| 29 | + uses: TriPSs/conventional-changelog-action@v3 |
| 30 | + with: |
| 31 | + github-token: ${{ secrets.github_token }} |
| 32 | + skip-version-file: "true" |
| 33 | + output-file: "false" |
| 34 | + skip-commit: "true" |
| 35 | + fallback-version: ${{ steps.version.outputs.version }} |
| 36 | + - name: Create Github Release |
| 37 | + id: create_release |
| 38 | + uses: actions/create-release@v1 |
| 39 | + if: ${{ steps.changelog.outputs.skipped == 'false' }} |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.github_token }} |
| 42 | + with: |
| 43 | + tag_name: ${{ steps.changelog.outputs.tag }} |
| 44 | + release_name: ${{ steps.changelog.outputs.tag }} |
| 45 | + body: ${{ steps.changelog.outputs.clean_changelog }} |
| 46 | + artifacts: |
| 47 | + needs: release |
| 48 | + env: |
| 49 | + GOPATH: ${{ github.workspace }} |
| 50 | + GO111MODULE: off |
| 51 | + strategy: |
| 52 | + matrix: |
| 53 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 54 | + include: |
| 55 | + - os: ubuntu-latest |
| 56 | + ARTIFACT: posh-linux-amd64 |
| 57 | + INSTALL_DEP: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh |
| 58 | + - os: macos-latest |
| 59 | + ARTIFACT: posh-darwin-amd64 |
| 60 | + INSTALL_DEP: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh |
| 61 | + - os: windows-latest |
| 62 | + ARTIFACT: posh-windows-amd64.exe |
| 63 | + INSTALL_DEP: choco install dep |
| 64 | + defaults: |
| 65 | + run: |
| 66 | + working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} |
| 67 | + runs-on: ${{ matrix.os }} |
| 68 | + steps: |
| 69 | + - name: Install Go |
| 70 | + uses: actions/setup-go@v2 |
| 71 | + with: |
| 72 | + go-version: 1.15.x |
| 73 | + - name: Checkout code |
| 74 | + uses: actions/checkout@v2 |
| 75 | + with: |
| 76 | + path: ./src/github.com/${{ github.repository }} |
| 77 | + - name: Install dependencies |
| 78 | + run: | |
| 79 | + ${{ matrix.INSTALL_DEP }} |
| 80 | + dep ensure -v |
| 81 | + - name: Build |
| 82 | + id: build |
| 83 | + run: go build -o ${{ matrix.ARTIFACT }} |
| 84 | + env: |
| 85 | + GOARCH: "amd64" |
| 86 | + - name: Upload Release Asset |
| 87 | + id: upload-release-asset |
| 88 | + uses: actions/upload-release-asset@v1 |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + with: |
| 92 | + upload_url: ${{ needs.release.outputs.upload_url }} |
| 93 | + asset_path: ./src/github.com/${{ github.repository }}/${{ matrix.ARTIFACT }} |
| 94 | + asset_name: ${{ matrix.ARTIFACT }} |
| 95 | + asset_content_type: application/octet-stream |
0 commit comments