Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

fix: release workflow #7

Merged
merged 17 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,27 @@ env:

jobs:
build:
name: go-build
name: go-build ${{ matrix.goos }}-${{ matrix.arch }}
runs-on: ubuntu-latest
mcdonnnj marked this conversation as resolved.
Show resolved Hide resolved
strategy:
matrix:
bin:
- pca-linux-amd64
- pca-linux-arm64
- pca-osx-amd64
- pca-osx-arm64
include:
- bin: pca-linux-amd64
- arch: amd64
bin: pca-linux-amd64
goos: linux
arch: amd64
- os: pca-linux-arm64

mcdonnnj marked this conversation as resolved.
Show resolved Hide resolved
- arch: arm64
bin: pca-linux-arm64
goos: linux
arch: arm64
- bin: pca-osx-amd64

- arch: amd64
bin: pca-osx-amd64
goos: darwin
arch: amd64
- bin: pca-osx-arm64

- arch: arm64
bin: pca-osx-arm64
goos: darwin
arch: arm64

steps:
- uses: actions/checkout@v3
- id: setup-go
Expand All @@ -56,15 +55,15 @@ jobs:
${{ hashFiles('go.sum') }}"
restore-keys: |
${{ env.BASE_CACHE_KEY }}
- name: Build ${{ matrix.os }}
- name: Build ${{ matrix.bin }}
run: go build -o ${{ matrix.bin }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.arch }}
- name: Upload to artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}
name: ${{ matrix.bin }}
path: ${{ matrix.bin }}
release:
name: go-release
Expand All @@ -76,8 +75,12 @@ jobs:
uses: actions/download-artifact@v3
with:
path: bin
- name: chmod executable
mcdonnnj marked this conversation as resolved.
Show resolved Hide resolved
run: chmod +x bin/pca-linux-amd64/pca-linux-amd64
- name: Set Tag Version
run: echo "VERSION=$(cat ./VERSION)" >> $GITHUB_ENV
run: |
echo "VERSION=v$(./bin/pca-linux-amd64/pca-linux-amd64 -version)" \
mcdonnnj marked this conversation as resolved.
Show resolved Hide resolved
>> $GITHUB_ENV
- name: Create Release
uses: actions/github-script@v6
with:
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import (
)

func main() {
// Print the version and exit if the -version flag is provided
version()

mux := chi.NewRouter()
mux.Get("/", controllers.HealthCheckHandler)

port := ":8080"
log.Printf("listening on port %s", port)
log.Printf("listening on port %s, version %s", port, Version)
log.Println(http.ListenAndServe(port, mux))
}
18 changes: 18 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"flag"
"fmt"
"os"
)

var Version = "0.0.1"

func version() {
v := flag.Bool("version", false, "prints current app version")
flag.Parse()
if *v {
fmt.Println(string(Version))
os.Exit(0)
}
}