Debian Codegraph @

.github/workflows/build.yml

raw symbols SCIP
1 name: Build and upload binaries
2 on:
3 release:
4 types: [published]
5 push:
6 pull_request:
7 permissions:
8 contents: read
9 jobs:
10 build:
11 name: Build binaries
12 runs-on: ubuntu-latest
13 strategy:
14 matrix:
15 include:
16 - {GOOS: linux, GOARCH: amd64}
17 - {GOOS: linux, GOARCH: arm, GOARM: 6}
18 - {GOOS: linux, GOARCH: arm64}
19 - {GOOS: darwin, GOARCH: arm64}
20 - {GOOS: darwin, GOARCH: amd64}
21 - {GOOS: windows, GOARCH: amd64}
22 - {GOOS: windows, GOARCH: arm64}
23 - {GOOS: freebsd, GOARCH: amd64}
24 steps:
25 - name: Checkout repository
26 uses: actions/checkout@v7
27 with:
28 fetch-depth: 0
29 persist-credentials: false
30 - name: Install Go
31 uses: actions/setup-go@v7
32 with:
33 go-version-file: go.mod
34 cache: false
35 - name: Build binary
36 run: |
37 VERSION="$(git describe --tags)"
38 DIR="$(mktemp -d)"
39 mkdir "$DIR/age"
40 go build -o "$DIR/age" -trimpath ./cmd/... ./extra/...
41 cp LICENSE "$DIR/age/LICENSE"
42 cat .github/workflows/LICENSE.suffix.txt >> "$DIR/age/LICENSE"
43 if [ "$GOOS" == "windows" ]; then
44 ( cd "$DIR"; zip age.zip -r age )
45 mv "$DIR/age.zip" "age-$VERSION-$GOOS-$GOARCH.zip"
46 else
47 tar -cvzf "age-$VERSION-$GOOS-$GOARCH.tar.gz" -C "$DIR" age
48 fi
49 env:
50 CGO_ENABLED: 0
51 GOOS: ${{ matrix.GOOS }}
52 GOARCH: ${{ matrix.GOARCH }}
53 GOARM: ${{ matrix.GOARM }}
54 - name: Upload workflow artifacts
55 uses: actions/upload-artifact@v7
56 with:
57 name: age-artifacts-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
58 path: age-*
59 source:
60 name: Package source code
61 runs-on: ubuntu-latest
62 steps:
63 - name: Checkout repository
64 uses: actions/checkout@v7
65 with:
66 fetch-depth: 0
67 persist-credentials: false
68 - name: Install Go
69 uses: actions/setup-go@v7
70 with:
71 go-version-file: go.mod
72 cache: false
73 - name: Create source tarball
74 run: |
75 VERSION="$(git describe --tags)"
76 DIR="$(mktemp -d)"
77 mkdir "$DIR/age"
78 git archive --format=tar.gz HEAD | tar -xz -C "$DIR/age"
79 ( cd "$DIR/age"; go mod vendor )
80 for cmd in "$DIR"/age/{cmd,extra}/*; do
81 echo "package main" >> "$cmd/version.go"
82 echo "" >> "$cmd/version.go"
83 echo "func init() { Version = \"$VERSION\" }" >> "$cmd/version.go"
84 done
85 tar -cvzf "age-$VERSION-source.tar.gz" -C "$DIR" age
86 - name: Upload workflow artifacts
87 uses: actions/upload-artifact@v7
88 with:
89 name: age-artifacts-source
90 path: age-*-source.tar.gz
91 upload:
92 name: Upload and attest release artifacts
93 if: github.event_name == 'release'
94 needs: [build, source]
95 permissions:
96 contents: write
97 attestations: write
98 id-token: write
99 runs-on: ubuntu-latest
100 steps:
101 - name: Download workflow artifacts
102 uses: actions/download-artifact@v8
103 with:
104 pattern: age-artifacts-*
105 merge-multiple: true
106 - name: Generate artifacts attestation
107 uses: actions/attest-build-provenance@v4
108 with:
109 subject-path: age-*
110 - name: Upload release artifacts
111 run: gh release upload "$GITHUB_REF_NAME" age-*
112 env:
113 GH_REPO: ${{ github.repository }}
114 GH_TOKEN: ${{ github.token }}