Skip to content

Commit

Permalink
git release cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pjmagee committed Jun 16, 2024
1 parent 7ddfcc1 commit 19f48d0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
with:
version: "latest"
verb: call
args: build --directory=./src
args: build --src=./src
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 8 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ on:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: write
packages: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build .NET Example
- name: Release
uses: dagger/[email protected]
with:
version: "latest"
verb: call
args: release --directory=./src --tag=env:TAG --token=env:GITHUB_TOKEN
args: release --git=. --tag=${{ github.ref_name }} --token=env:GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[![Dota2 Helper Build](https://github.com/pjmagee/dota2-helper/actions/workflows/build.yaml/badge.svg)](https://github.com/pjmagee/dota2-helper/actions/workflows/build.yaml)

# Dota 2 Helper
![Latest Release](https://img.shields.io/badge/dynamic/json?label=Latest%20release&query=$.tag_name&url=https%3A%2F%2Fapi.github.com%2Frepos%2Fpjmagee%2Fdota2-helper%2Freleases%2Flatest&style=flat&color=blue)

# Dota 2 Helper

An objective timer tracker with audio notifications for Dota 2. This application is designed to help players keep track of important in-game events such as stacking, power runes, bounty runes, and more. The application is designed to be used in conjunction with the Game State Integration feature of Dota 2.

Expand Down
8 changes: 4 additions & 4 deletions dagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "Dota2Helper",
"sdk": "go",
"dependencies": [
{
"name": "arc",
"source": "github.com/sagikazarmark/daggerverse/arc@b45dbd7448bb967aca4a538af9ce7f042abf0316"
},
{
"name": "gh",
"source": "github.com/sagikazarmark/daggerverse/gh@b45dbd7448bb967aca4a538af9ce7f042abf0316"
},
{
"name": "arc",
"source": "github.com/sagikazarmark/daggerverse/arc@b45dbd7448bb967aca4a538af9ce7f042abf0316"
}
],
"source": "dagger",
Expand Down
32 changes: 19 additions & 13 deletions dagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import (
"context"
"dagger/dota-2-helper/internal/dagger"
"fmt"
"strings"
)

type Dota2Helper struct{}

func (m *Dota2Helper) Build(ctx context.Context, directory *Directory) (string, error) {
func (m *Dota2Helper) Build(ctx context.Context, src *Directory) (string, error) {
return dag.Container().
From("mcr.microsoft.com/dotnet/sdk:8.0").
WithDirectory("/src", directory, dagger.ContainerWithDirectoryOpts{
WithDirectory("/src", src, dagger.ContainerWithDirectoryOpts{
Exclude: []string{"**/bin/**", "**/obj/**"},
}).
WithWorkdir("/src").
Expand All @@ -35,11 +36,11 @@ func (m *Dota2Helper) Build(ctx context.Context, directory *Directory) (string,
Stdout(ctx)
}

func (m *Dota2Helper) PublishWindows(ctx context.Context, directory *Directory, version string) *dagger.Container {
func (m *Dota2Helper) PublishWindows(ctx context.Context, src *Directory, version string) *dagger.Container {

return dag.Container().
From("mcr.microsoft.com/dotnet/sdk:8.0").
WithDirectory("/src", directory, dagger.ContainerWithDirectoryOpts{
WithDirectory("/src", src, dagger.ContainerWithDirectoryOpts{
Exclude: []string{"**/bin/**", "**/obj/**"},
}).
WithWorkdir("/src").
Expand All @@ -61,29 +62,34 @@ func (m *Dota2Helper) PublishWindows(ctx context.Context, directory *Directory,

func (m *Dota2Helper) Release(
ctx context.Context,
directory *Directory,
git *Directory,
tag string,
token *dagger.Secret) (dagger.Void, error) {
token *dagger.Secret) error {

var title string = ""
published := m.PublishWindows(ctx, directory, tag)
version := strings.TrimPrefix(tag, "v")
published := m.PublishWindows(ctx, git.Directory("src"), version)
assets := published.Directory("/publish")

gh := dag.Gh(dagger.GhOpts{
Token: token,
Repo: "github.com/pjmagee/dota2-helper",
Token: token,
Repo: "github.com/pjmagee/dota2-helper",
Source: git,
})

zip := dag.Arc(dagger.ArcOpts{}).ArchiveDirectory(fmt.Sprintf("Dota2Helper_%s_windows_amd64", tag), assets).Zip()

ghRelease := gh.Release()

return ghRelease.Create(ctx, tag, title, dagger.GhReleaseCreateOpts{
_, err := gh.Release().Create(ctx, tag, "", dagger.GhReleaseCreateOpts{
Target: "main",
Files: []*dagger.File{zip},
Latest: true,
VerifyTag: true,
Draft: true,
GenerateNotes: true,
})

if err != nil {
return err
}

return nil
}

0 comments on commit 19f48d0

Please sign in to comment.