Skip to content

Commit

Permalink
CI/bin releases worlfow (#27)
Browse files Browse the repository at this point in the history
* chore: Adds workflow to create releases

* chore: Update docker title

* fix: Fixes YAML indentation. I'm a n00b

* fix: Yaml indentation. Again
  • Loading branch information
Lissy93 authored Jun 10, 2024
1 parent bfeb9b2 commit ed5c59e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 🐳 Build + Publish Multi-Platform Image
name: 🐳 Publish Docker

on:
workflow_dispatch:
Expand Down
89 changes: 75 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,55 @@
name: 🛠️ Compile Release Assets
# Upon a new tag being pushed to git, this workflow will:
# - Get the app version (from tag)
# - Draft a new release with release notes
# - Compile the Go binary for all platforms
# - Attach the compiled binaries to the release
name: 🏗️ Release Binaries

on:
release:
types: [created]
push:
tags:
- '^[0-9]+\.[0-9]+\.[0-9]+$'
workflow_dispatch:
inputs:
tag:
description: 'Tag to draft a release for (must already exist)'
required: true

jobs:
releases-matrix:
name: Release Go Binary
create-draft-release:
name: Create Draft Release 1️⃣
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create_release.outputs.id }}
tag_name: ${{ steps.get_tag_name.outputs.tag_name }}
steps:
- name: Checkout code 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get Tag Name 🏷️
id: get_tag_name
run: echo "::set-output name=tag_name::${GITHUB_REF##*/}"

- name: Create Draft Release 📝
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
release_name: Release ${{ github.event.inputs.tag || github.ref_name }}
draft: true
prerelease: false
generate_release_notes: true

- name: Output new release URL ↗️
run: 'echo "Draft release URL: ${{ steps.create_release.outputs.html_url }}"'

compile-and-attach:
name: Compile and Attach Go Binary 2️⃣
needs: create-draft-release
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -20,13 +63,31 @@ jobs:
steps:
- name: Checkout code 🛎️
uses: actions/checkout@v3
- name: Compile Go binaries 🏗️
uses: wangyoucao577/go-release-action@v1.29

- name: Set up Go 🏗️
uses: actions/setup-go@v2
with:
go-version: 1.22.4

- name: Compile Go binaries 🔨
run: |
go build -ldflags "-X main.Version=${{ needs.create-draft-release.outputs.tag_name }}" -o web-check-api .
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
- name: Upload Go binaries ⤴️
uses: actions/upload-artifact@v2
with:
name: web-check-api-${{ matrix.goos }}-${{ matrix.goarch }}
path: web-check-api

- name: Attach binaries to release 📎
uses: actions/upload-release-asset@v1
with:
github_token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.22.4
project_path: '.'
binary_name: web-check-api
md5sum: true
upload_url: ${{ needs.create-draft-release.outputs.release_id }}
asset_path: web-check-api
asset_name: web-check-api-${{ matrix.goos }}-${{ matrix.goarch }}
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}

0 comments on commit ed5c59e

Please sign in to comment.