Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
x0ddf committed Nov 24, 2024
1 parent 2df53c1 commit ee19445
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
49 changes: 32 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
push:
tags: [ 'v*' ]


env:
PLATFORMS: "linux darwrin windows"
ARCH: "amd64 arm64"
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -33,6 +35,7 @@ jobs:
version: latest

docker:
name: Release docker image
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
Expand Down Expand Up @@ -78,33 +81,45 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}

release:
name: GH release
needs: docker
runs-on: ubuntu-latest
strategy:
matrix:
goosarch:
- 'linux/amd64'
- 'linux/arm64'
- 'darwin/amd64'
- 'darwin/arm64'
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Build release binaries
- name: Get OS and arch info
run: |
GOOS=linux GOARCH=amd64 go build -o tiny-status-page-linux-amd64
GOOS=linux GOARCH=arm64 go build -o tiny-status-page-linux-arm64
GOOS=darwin GOARCH=amd64 go build -o tiny-status-page-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o tiny-status-page-darwin-arm64
- name: Create Release
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
BINARY_NAME=${{github.repository}}-$GOOS-$GOARCH
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
- name: Build
run: |
go build -o "$BINARY_NAME" ./cmd/backend
- name: Release Notes
run:
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md"
- name: Release with Notes
uses: softprops/action-gh-release@v1
with:
files: |
tiny-status-page-linux-amd64
tiny-status-page-linux-arm64
tiny-status-page-darwin-amd64
tiny-status-page-darwin-arm64
generate_release_notes: true
body_path: ".github/RELEASE-TEMPLATE.md"
draft: true
files: ${{env.BINARY_NAME}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN go mod download
COPY . .

# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -o tiny-status-page ./cmd/backend
RUN go build -o tiny-status-page ./cmd/backend

# Final stage
FROM alpine:3.19
Expand Down

0 comments on commit ee19445

Please sign in to comment.