Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions .github/actions/codegen-and-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: "Codegen and Test"
description: "Run go generate and go test"
runs:
using: "composite"
steps:
- run: go generate ./...
shell: bash
- run: go test ./...
shell: bash
25 changes: 25 additions & 0 deletions .github/actions/discord-webhook/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Discord Webhook"
description: "Send PR info to Discord"
inputs:
webhook-url:
description: "Discord webhook URL"
required: true
pr-title:
description: "Title of the pull request"
required: false
pr-body:
description: "Body of the pull request"
required: false
pr-url:
description: "URL of the pull request"
required: false
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- uses: tsickert/[email protected]
with:
webhook-url: ${{ inputs.webhook-url }}
embed-title: ${{ inputs.pr-title }}
embed-description: ${{ inputs.pr-body }}
embed-url: ${{ inputs.pr-url }}
9 changes: 9 additions & 0 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: "Setup Go"
description: "Checkout and setup Go using go.mod"
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
29 changes: 29 additions & 0 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Auto Tag

on:
push:
branches:
- master
- '**'

permissions:
contents: write

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to access all tags

- name: Create tag using commit message
id: tagger
uses: mathieudutour/[email protected]
with:
tag_prefix: 'v'
default_bump: 'patch'
default_prerelease_bump: 'prerelease'
dry_run: false # Set to false for actual tagging in production
github_token: ${{ secrets.GITHUB_TOKEN }}

62 changes: 9 additions & 53 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# This workflow will: build gomud for multiple os/architectures
# archive the binaries and create a new release for users to easily download

name: Build and release

on:
push:
tags: ['v*.*.*']
branches:
- master

permissions:
contents: write
Expand All @@ -18,33 +16,15 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Show version
run: echo 'Releasing version $RELEASE_VERSION'

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run code generation
run: go generate ./...

- name: Run tests
run: go test ./...
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/codegen-and-test

build:
runs-on: ubuntu-latest
needs: 'test'
needs: test
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: ./.github/actions/setup-go

- name: Create bin directory
run: mkdir -p bin/
Expand Down Expand Up @@ -75,7 +55,7 @@ jobs:

release:
runs-on: ubuntu-latest
needs: "build"
needs: build
steps:
- uses: actions/checkout@v4

Expand All @@ -88,8 +68,7 @@ jobs:
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
echo "COMMIT_SHORT_SHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV

- name: Archive release
run: zip -r bin/${{ env.RELEASE_FILENAME }}-${{ env.RELEASE_VERSION }}.zip bin/
Expand All @@ -102,26 +81,3 @@ jobs:
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

message:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
id: get_pr_data
with:
script: |
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0];
- name: Discord Webhook Action
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
embed-title: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).title || '🎉 New update on `master` branch' }}
embed-description: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).body || 'No description provided.' }}
embed-url: ${{ steps.get_pr_data.outputs.result && fromJson(steps.get_pr_data.outputs.result).html_url || github.event.compare }}

41 changes: 41 additions & 0 deletions .github/workflows/discord-notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Notify Discord

on:
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is only triggered on pull_request.opened, but includes logic for release events. Add a release: types: [published] trigger (or similar) under on to send notifications when new releases are published.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow only listens to Pull Request opened events but includes release metadata steps; add a release event (e.g., release: types: [published]) or remove the release logic to align triggers with steps.

Copilot uses AI. Check for mistakes.
pull_request:
types:
- opened

permissions:
contents: read

jobs:
notify-discord:
runs-on: ubuntu-latest
steps:
- name: Get PR Metadata
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
id: pr_meta
with:
script: |
core.setOutput('title', context.payload.pull_request.title || '')
core.setOutput('body', context.payload.pull_request.body || '')
core.setOutput('url', context.payload.pull_request.html_url || '')

- name: Get Release Metadata
if: github.event_name == 'release'
uses: actions/github-script@v6
id: release_meta
with:
script: |
core.setOutput('title', context.payload.release.name || context.payload.release.tag_name || '')
core.setOutput('body', context.payload.release.body || '')
core.setOutput('url', context.payload.release.html_url || '')

- name: Send Discord Message
uses: ./.github/actions/discord-webhook
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
pr-title: ${{ steps.pr_meta.outputs.title }}${{ steps.release_meta.outputs.title }}
pr-body: ${{ steps.pr_meta.outputs.body }}${{ steps.release_meta.outputs.body }}
pr-url: ${{ steps.pr_meta.outputs.url }}${{ steps.release_meta.outputs.url }}
25 changes: 3 additions & 22 deletions .github/workflows/docker-package.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,50 @@
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images

name: Docker Package

on:
workflow_dispatch:
push:
branches:
- master
tags:
- 'v*.*.*'
pull_request:
branches:
- master

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
RELEASE_VERSION: ${{ github.ref_name }}

jobs:
package:
runs-on: ubuntu-latest

# Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go

# https://github.com/docker/login-action
- name: Log in to the Container registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
password: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/docker/metadata-action
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
# set latest tag for master branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
type=ref,event=tag
type=ref,event=pr
type=sha

# https://github.com/docker/build-push-action
# For pull request, only ensures that the docker build succeeds, does not push the image.
# See: https://github.com/docker/build-push-action/issues/751
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
Expand All @@ -72,12 +55,10 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# https://github.com/actions/attest-build-provenance
- name: Generate artifact attestation
if: github.event_name != 'pull_request'
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
# https://github.com/actions/attest-build-provenance/issues/71#issuecomment-2108140285
push-to-registry: false
24 changes: 10 additions & 14 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
name: run-tests
name: Run Tests

on:
pull_request:
branches: [master]
workflow_dispatch:
branches:
- master
- '**'

permissions:
contents: read
pull-requests: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run code generation
run: go generate ./...

- name: Run tests
run: make test
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/codegen-and-test
Loading