Delete build directory #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go CI/CD | |
on: | |
push: | |
branches: [ "main" ] | |
tags: [ "v*" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
GO_VERSION: '1.21' | |
JAVA_VERSION: '17' | |
BINARY_NAME: 'minecrap_hoster' | |
VERSION: '1.0.0' | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
- name: Run golangci-lint | |
run: golangci-lint run ./... | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
needs: lint | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Download test dependencies | |
run: | | |
mkdir -p static | |
curl -o fabric-server-mc.1.20.1-loader.0.16.5-launcher.1.0.1.jar https://meta.fabricmc.net/v2/versions/loader/1.20.1/0.14.21/0.11.2/server/jar | |
- name: Run tests | |
run: | | |
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | |
- name: Upload coverage reports | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.txt | |
fail_ci_if_error: false | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Build using Makefile | |
run: | | |
# Set version from git tag if available | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/v} | |
fi | |
make build-all VERSION=$VERSION | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: releases | |
path: | | |
build/*.zip | |
build/*.tar.gz | |
retention-days: 7 | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Download built artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: releases | |
path: releases | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
releases/*.zip | |
releases/*.tar.gz | |
draft: false | |
prerelease: false | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |