Github Action 学习

OneZ3r0 Lv3

前言

学点GitHub workflow,懒狗直接用来编译开源工具了

https://github.com/marketplace?type=actions

https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md

成果

参考了一下这位老哥的,学着写了下,尝试打包了adaptixc2以及配套的插件

https://github.com/OneZ3r0/AdaptixC2/blob/main/.github/workflows/build.yml

https://github.com/OneZ3r0/Extension-Kit/blob/main/.github/workflows/build.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: build and release

on:
push:
branches: ["main"]
tags: ["v*"]
workflow_dispatch:

permissions:
contents: write

jobs:
build:
name: Build all (linux)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Set up go environment
uses: actions/setup-go@v5
with:
go-version: '1.25'
check-latest: true
cache-dependency-path: AdaptixServer/go.sum

- name: Pre install all dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ build-essential make cmake mingw-w64 g++-mingw-w64 libssl-dev qt6-base-dev qt6-base-private-dev libxkbcommon-dev qt6-websockets-dev qt6-declarative-dev
# for windows 7 support by gopher agent
git clone https://github.com/Adaptix-Framework/go-win7 /tmp/go-win7
sudo mv /tmp/go-win7 /usr/lib/

- name: Make
run: make all

- name: Compress release files
run: |
cd dist
tar -czvf ../AdaptixC2-Linux-x64.tar.gz .

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: dist-files
path: AdaptixC2-Linux-x64.tar.gz

- name: Release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
files: AdaptixC2-Linux-x64.tar.gz
generate_release_notes: true

push 并打 tag

1
2
3
4
5
6
7
8
git add .

git commit -m "added workflow"
git push origin main

git tag v1.0

git push origin <tag_name>

Rubeus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: build and release

on:
push:
branches:
- main
- master
tags:
- "v*"
workflow_dispatch:

jobs:
build:
name: Build (Release)
runs-on: windows-2022
permissions:
contents: read

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

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Setup NuGet
uses: NuGet/setup-nuget@v2

- name: Install .NET Framework v4.0 reference assemblies
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
nuget install Microsoft.NETFramework.ReferenceAssemblies.net40 -Version 1.0.3 -OutputDirectory packages

$refPath = Resolve-Path "packages/Microsoft.NETFramework.ReferenceAssemblies.net40.1.0.3/build/.NETFramework/v4.0"
"FRAMEWORK_PATH_OVERRIDE=$refPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Build
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
msbuild .\Rubeus.sln /m /p:Configuration=Release /p:Platform="Any CPU" /p:FrameworkPathOverride="$env:FRAMEWORK_PATH_OVERRIDE"

- name: Stage artifacts
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item -Path .\Rubeus\bin\Release\* -Destination dist -Recurse -Force

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Rubeus-Release
path: dist/**
if-no-files-found: error

release:
name: GitHub Release (tags)
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Rubeus-Release
path: dist

- name: Package
run: |
cd dist
zip -r ../Rubeus-Release.zip .

- name: Create release
uses: softprops/action-gh-release@v2
with:
files: Rubeus-Release.zip
  • 标题: Github Action 学习
  • 作者: OneZ3r0
  • 创建于 : 2026-01-19 10:57:39
  • 更新于 : 2026-02-20 20:05:18
  • 链接: https://blog.onez3r0.top/2026/01/19/github-action-cdci/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
目录
Github Action 学习