mirror of
https://github.com/lukaszraczylo/go-simple-graphql.git
synced 2026-10-17 01:17:43 +00:00
Improve builds to include automagic releases.
This commit is contained in:
+53
-10
@@ -1,17 +1,60 @@
|
|||||||
on: push
|
name: Test and release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "*"
|
||||||
|
|
||||||
name: Run unit tests
|
|
||||||
jobs:
|
jobs:
|
||||||
checks:
|
prepare:
|
||||||
|
name: Preparing build context
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
RELEASE_VERSION: ${{ steps.get_env.outputs.RELEASE_VERSION }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: '0'
|
||||||
|
- name: Setting environment variables
|
||||||
|
id: get_env
|
||||||
|
run: |
|
||||||
|
TMP_GITHUB_COMMITS_COUNT=$(git rev-list --count HEAD)
|
||||||
|
TMP_GITHUB_COUNT_NUMBER=$(echo ${GITHUB_RUN_NUMBER})
|
||||||
|
echo "::set-output name=RELEASE_VERSION::1.$TMP_GITHUB_COMMITS_COUNT.$TMP_GITHUB_COUNT_NUMBER"
|
||||||
|
|
||||||
|
tests:
|
||||||
name: Run unit tests
|
name: Run unit tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- name: Checkout repo
|
||||||
- name: run
|
uses: actions/checkout@v2
|
||||||
uses: cedrickring/[email protected]
|
- name: Run unit tests
|
||||||
with:
|
uses: cedrickring/[email protected]
|
||||||
args: |
|
with:
|
||||||
make prepare
|
args: |
|
||||||
make test CI_RUN=${CI}
|
make prepare;
|
||||||
|
make test CI_RUN=${CI}
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ prepare, tests ]
|
||||||
|
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@main
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.event.repository.name }}/${{ needs.prepare.outputs.RELEASE_VERSION }}
|
||||||
|
release_name: v${{ needs.prepare.outputs.RELEASE_VERSION }}
|
||||||
|
body: |
|
||||||
|
Released automatically after merge to master / main.
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
@@ -6,10 +6,10 @@ ifeq ($(CI_RUN), true)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
prepare:
|
prepare:
|
||||||
go get -u -v github.com/go-critic/go-critic/cmd/gocritic
|
go get github.com/go-critic/go-critic/cmd/gocritic
|
||||||
|
|
||||||
test:
|
test:
|
||||||
# gocritic check
|
gocritic check
|
||||||
go test $(ADDITIONAL_BUILD_FLAGS) -v -coverprofile cover.out -memprofile mem.out
|
go test $(ADDITIONAL_BUILD_FLAGS) -v -coverprofile cover.out -memprofile mem.out
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
|
|||||||
Reference in New Issue
Block a user