diff --git a/.github/workflows/pipeline.yml b/.github/workflows/ci.yml similarity index 97% rename from .github/workflows/pipeline.yml rename to .github/workflows/ci.yml index 6f6cfd5..9dd0c63 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Go +name: CI on: push: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..575d82a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... + + release: + name: Create Release + needs: test + runs-on: ubuntu-latest + outputs: + upload_url: ${{steps.create_release.outputs.upload_url}} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + tag_name: ${{github.ref}} + release_name: ${{github.ref}} + + build-executable: + name: Build an executable + needs: release + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Build + run: go build -v -o git-story-view ./cli/main.go + - name: Zip up release + run: tar -zvc git-story-view > ${{github.workspace}}/git-story-darwin-x64.tar.gz + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + upload_url: ${{needs.release.outputs.upload_url}} + asset_path: ./git-story-darwin-x64.tar.gz + asset_name: git-story-darwin-x64.tar.gz + asset_content_type: application/gzip