From 9f6fbc296bd16b48540b61c467c2da932119b473 Mon Sep 17 00:00:00 2001 From: Greg Furman Date: Sat, 27 Apr 2024 11:35:28 +0200 Subject: [PATCH] Add github build and release workflows --- .github/workflows/build.yml | 41 +++++++++++++++++++ .github/workflows/release.yml | 76 +++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..23df776 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Go package + +on: [push] + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21.x + + - name: golangci-lint + uses: golangci/golangci-lint-action@v5 + with: + version: v1.57 + + - name: Install Dependencies + run: go get . + + - name: Lint + run: go build -o service main.go + + - name: Test + run: go test -v ./... + + - name: Build + run: go build -o service main.go \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..af00c88 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,76 @@ +name: tag-release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + tag: + if: ${{ github.repository == 'gregfurman/pipescope' }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: /usr/bin/git config --global user.email actions@github.com + - run: /usr/bin/git config --global user.name 'GitHub Actions Release Tagger' + - run: hack/tag-release.sh + id: tag_release + outputs: + release_tag: ${{ steps.tag_release.outputs.release_tag }} + + release: + needs: tag + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + + - name: Get previous tag + id: prev_tag + run: echo "::set-output name=PREV_TAG::$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))" + + - name: Get commit log + id: commit_log + run: echo "::set-output name=COMMIT_LOG::$(git log --pretty=format:'- %s (%h)' ${PREV_TAG}..HEAD)" + + - name: Setup Golang + uses: actions/setup-go@v2 + with: + go-version: 1.21.x + + - name: Build Go Binary + run: | + GOOS=linux GOARCH=amd64 go build -o pipescope main.go + - uses: actions/upload-artifact@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: ecr-credential-provider + path: ecr-credential-provider + + - uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.tag.outputs.release_tag }} + release_name: ${{ needs.tag.outputs.release_tag }} + body: | + Changes in this release: + ${{ steps.commit_log.outputs.COMMIT_LOG }} + draft: false + prerelease: false + + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./pipescope + asset_name: pipescope + asset_content_type: application/octet-stream \ No newline at end of file