Merge pull request #11 from asdf-vm/tb/golang-builds

feat(golang-rewrite): setup Golang CI builds
This commit is contained in:
Trevor Brown 2024-02-03 14:50:57 -05:00 committed by Trevor Brown
commit fb8fbcfa1c
5 changed files with 155 additions and 1 deletions

View File

@ -40,7 +40,7 @@ jobs:
- name: Lint
run: staticcheck -tests -show-ignored ./...
- name: Build
run: build -v ./...
run: go build -v ./...
actions:
runs-on: ubuntu-latest

98
.github/workflows/release-build.yml vendored Normal file
View File

@ -0,0 +1,98 @@
name: Release (and build Golang binaries)
# This workflow should eventually replace the one in release.yml completely.
permissions:
contents: "write"
# Eventually this workflow will only be run when a
#on:
# push:
# tags:
# - 'v[0-9]+.*'
# Typically we'd only want to build binaries and a release when a new tag is
# pushed. But since this is a new projectu I'm doing it on every new commit to
# the master branch. This will make it easy to download and test binaries for
# each new version.
on:
push:
branches:
- master
# TODO: Uncomment once this is merged and we're ready to prepare the first
# public tagged version of the Golang implementation.
#jobs:
# release:
# runs-on: ubuntu-latest
# steps:
# - uses: GoogleCloudPlatform/release-please-action@v4
# name: create release
# with:
# release-type: simple
# bump-minor-pre-major: true # remove this to enable breaking changes causing 1.0.0 tag
# changelog-types: |
# [
# { "type": "feat", "section": "Features", "hidden": false },
# { "type": "fix", "section": "Patches", "hidden": false },
# { "type": "docs", "section": "Documentation", "hidden": false }
# ]
# extra-files: |
# SECURITY.md
# docs/guide/getting-started.md
# docs/pt-br/guide/getting-started.md
# docs/zh-hans/guide/getting-started.md
jobs:
create-release:
name: create-release
runs-on: ubuntu-22.04
# env:
# Set to force version number, e.g., when no tag exists.
# ASDF_VERSION: TEST-0.1.0
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
asdf_version: ${{ env.ASDF_VERSION }}
steps:
- name: Get the release version from the tag
shell: bash
if: env.ASDF_VERSION == ''
run: |
# Apparently, this is the right way to get a tag name. Really?
#
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
#echo "ASDF_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "ASDF_VERSION=$GITHUB_SHA" >> "$GITHUB_ENV"
echo "version is: ${{ env.ASDF_VERSION }}"
- uses: actions/checkout@v3
- name: Create GitHub release
id: release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ env.ASDF_VERSION }}
name: ${{ env.ASDF_VERSION }}
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.5'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@ -6,3 +6,5 @@ repository
.vagrant
keyrings
/tmp
dist/

46
.goreleaser.yaml Normal file
View File

@ -0,0 +1,46 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 1
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

8
main.go Normal file
View File

@ -0,0 +1,8 @@
package main
import "fmt"
// Placeholder for the real code
func main() {
fmt.Println("Late but latest -- Rajinikanth")
}