From b3c2f80fb3cf1aa284959d5a28fbfe991f38d61c Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 10 Jun 2024 12:30:41 +0100 Subject: [PATCH 1/4] chore: Adds workflow to create releases --- .github/workflows/release.yml | 96 ++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b761739..04d12c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: @@ -18,15 +61,34 @@ jobs: - goarch: arm64 goos: windows steps: - - name: Checkout code ๐Ÿ›Ž๏ธ - uses: actions/checkout@v3 - - name: Compile Go binaries ๐Ÿ—๏ธ - uses: wangyoucao577/go-release-action@v1.29 - 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 + - name: Checkout code ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 + + - 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: + 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 }} From 6aef910b07c137dfd4fcc2638065fbc3cb1b6d31 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 10 Jun 2024 12:30:51 +0100 Subject: [PATCH 2/4] chore: Update docker title --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a9cc3aa..554e407 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: ๐Ÿณ Build + Publish Multi-Platform Image +name: ๐Ÿณ Publish Docker on: workflow_dispatch: From ea060702c4e0cd24c783b31c6d4f25a43eb77427 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 10 Jun 2024 12:35:00 +0100 Subject: [PATCH 3/4] fix: Fixes YAML indentation. I'm a n00b --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04d12c2..8972450 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,7 +60,7 @@ jobs: goos: darwin - goarch: arm64 goos: windows - steps: + steps: - name: Checkout code ๐Ÿ›Ž๏ธ uses: actions/checkout@v3 From 249a2117ca370998da53e7454989e5e2ca527dc8 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 10 Jun 2024 12:38:33 +0100 Subject: [PATCH 4/4] fix: Yaml indentation. Again --- .github/workflows/release.yml | 49 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8972450..c05bc9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,35 +60,34 @@ jobs: goos: darwin - goarch: arm64 goos: windows - steps: - - name: Checkout code ๐Ÿ›Ž๏ธ - uses: actions/checkout@v3 + steps: + - name: Checkout code ๐Ÿ›Ž๏ธ + uses: actions/checkout@v3 - - name: Set up Go ๐Ÿ—๏ธ - uses: actions/setup-go@v2 - with: - go-version: 1.22.4 + - 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 . + - 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: 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: - 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 }} + - name: Attach binaries to release ๐Ÿ“Ž + uses: actions/upload-release-asset@v1 + with: + 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 }}