1+ name : Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+ workflow_dispatch :
8+ inputs :
9+ version :
10+ description : ' Version tag (e.g., v1.0.0)'
11+ required : true
12+ type : string
13+
14+ permissions :
15+ contents : write
16+
17+ jobs :
18+ build :
19+ runs-on : ubuntu-latest
20+ strategy :
21+ matrix :
22+ include :
23+ - os : linux
24+ arch : amd64
25+ binary : docker-inspector
26+ - os : darwin
27+ arch : amd64
28+ binary : docker-inspector
29+ - os : darwin
30+ arch : arm64
31+ binary : docker-inspector
32+ - os : windows
33+ arch : amd64
34+ binary : docker-inspector.exe
35+
36+ steps :
37+ - uses : actions/checkout@v4
38+
39+ - name : Set up Go
40+ uses : actions/setup-go@v5
41+ with :
42+ go-version : ' 1.21'
43+
44+ - name : Build internal inspector
45+ env :
46+ GOOS : linux
47+ GOARCH : amd64
48+ CGO_ENABLED : 0
49+ run : |
50+ go build -o cmd/docker-inspector/internal-inspector ./cmd/internal-inspector
51+
52+ - name : Build platform binary
53+ env :
54+ GOOS : ${{ matrix.os }}
55+ GOARCH : ${{ matrix.arch }}
56+ CGO_ENABLED : 0
57+ run : |
58+ go build -o ${{ matrix.binary }} ./cmd/docker-inspector
59+
60+ - name : Create release archive
61+ run : |
62+ zip docker-inspector-${{ matrix.os }}-${{ matrix.arch }}.zip ${{ matrix.binary }}
63+
64+ - name : Upload artifact
65+ uses : actions/upload-artifact@v4
66+ with :
67+ name : binary-${{ matrix.os }}-${{ matrix.arch }}
68+ path : docker-inspector-${{ matrix.os }}-${{ matrix.arch }}.zip
69+ retention-days : 1
70+
71+ release :
72+ needs : build
73+ runs-on : ubuntu-latest
74+ steps :
75+ - name : Download all artifacts
76+ uses : actions/download-artifact@v4
77+ with :
78+ pattern : binary-*
79+ merge-multiple : true
80+
81+ - name : Get version
82+ id : get_version
83+ run : |
84+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
85+ echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
86+ else
87+ echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
88+ fi
89+
90+ - name : Create Release
91+ uses : softprops/action-gh-release@v1
92+ env :
93+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
94+ with :
95+ tag_name : ${{ steps.get_version.outputs.version }}
96+ name : Release ${{ steps.get_version.outputs.version }}
97+ files : docker-inspector-*.zip
98+ generate_release_notes : true
99+ draft : false
100+ prerelease : false
0 commit comments