|
1 | | -name: hinge Release |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - 'v*' |
7 | 7 |
|
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
8 | 11 | jobs: |
9 | 12 | release: |
10 | | - name: Create Release |
11 | 13 | runs-on: ubuntu-latest |
12 | | - outputs: |
13 | | - upload_url: ${{ steps.upload_url.outputs.upload_url }} |
14 | | - |
15 | 14 | steps: |
16 | | - - name: Checkout code |
| 15 | + - |
| 16 | + name: Checkout |
17 | 17 | uses: actions/checkout@v2 |
18 | | - |
19 | | - - name: Create Release |
20 | | - id: create_release |
21 | | - uses: actions/create-release@v1 |
22 | | - env: |
23 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
24 | 18 | with: |
25 | | - tag_name: ${{ github.ref }} |
26 | | - release_name: Release ${{ github.ref }} |
27 | | - body: | |
28 | | - This release has the following changes: |
29 | | - - README Updates. |
30 | | - draft: false |
31 | | - prerelease: false |
32 | | - |
33 | | - - name: Fix Upload URL |
34 | | - id: upload_url |
35 | | - run: echo ::set-output name=upload_url::$(echo "${{ steps.create_release.outputs.upload_url }}" | cut -d"{" -f1) |
36 | | - |
37 | | - - name: Echo upload url |
38 | | - run: echo "${{ steps.upload_url.outputs.upload_url }}" |
39 | | - |
40 | | - build: |
41 | | - needs: release |
42 | | - strategy: |
43 | | - matrix: |
44 | | - os: ["darwin", "freebsd", "linux", "netbsd", "openbsd", "windows"] |
45 | | - arch: ["amd64", "arm64", "arm"] |
46 | | - |
47 | | - env: |
48 | | - UPLOAD_URL: ${{ needs.release.outputs.upload_url }} |
49 | | - |
50 | | - name: Build and Upload Assets |
51 | | - runs-on: ubuntu-latest |
52 | | - steps: |
53 | | - - name: Checkout code |
54 | | - uses: actions/checkout@v2 |
55 | | - |
56 | | - - name: Setup Go |
| 19 | + fetch-depth: 0 |
| 20 | + - |
| 21 | + name: Set up Go |
57 | 22 | uses: actions/setup-go@v2 |
58 | 23 | with: |
59 | | - go-version: '1.18' |
60 | | - |
61 | | - - name: Get the version |
62 | | - id: get_version |
63 | | - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/} |
64 | | - |
65 | | - - name: Generate SBOM |
66 | | - uses: CycloneDX/gh-gomod-generate-sbom@v0.3.0 |
| 24 | + go-version: 1.18 |
| 25 | + - |
| 26 | + name: Run GoReleaser |
| 27 | + uses: goreleaser/goreleaser-action@v2 |
67 | 28 | with: |
68 | | - include-stdlib: true |
69 | | - json: true |
70 | | - output: sbom.json |
71 | | - resolve-licenses: true |
72 | | - version: "^v0" |
73 | | - |
74 | | - - name: Build amd64 Assets |
75 | | - if: matrix.arch == 'amd64' |
76 | | - run: | |
77 | | - echo "${{ matrix.os }} ${{ matrix.arch }}" |
78 | | - env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/hinge |
79 | | - env: |
80 | | - FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }} |
81 | | - |
82 | | - - name: Build arm64 Assets |
83 | | - if: matrix.arch == 'arm64' && matrix.os == 'linux' |
84 | | - run: | |
85 | | - echo "${{ matrix.os }} ${{ matrix.arch }}" |
86 | | - env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/hinge |
87 | | - env: |
88 | | - FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }} |
89 | | - |
90 | | - - name: Build arm Assets |
91 | | - if: matrix.arch == 'arm' && (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd') |
92 | | - run: | |
93 | | - echo "${{ matrix.os }} ${{ matrix.arch }}" |
94 | | - env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/hinge |
95 | | - env: |
96 | | - FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }} |
97 | | - |
98 | | - - name: Upload SBoM |
99 | | - run: | |
100 | | - curl \ |
101 | | - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
102 | | - -H "Content-Type: $(file -b --mime-type $FILE)" \ |
103 | | - --data-binary @$FILE \ |
104 | | - "$UPLOAD_URL?name=$(basename $FILE)" |
105 | | - env: |
106 | | - FILE: sbom.json |
107 | | - |
108 | | - - name: Upload amd64 Non-Windows |
109 | | - if: matrix.os != 'windows' && matrix.arch == 'amd64' |
110 | | - run: | |
111 | | - curl \ |
112 | | - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
113 | | - -H "Content-Type: $(file -b --mime-type $FILE)" \ |
114 | | - --data-binary @$FILE \ |
115 | | - "$UPLOAD_URL?name=$(basename $FILE)" |
116 | | - env: |
117 | | - FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }} |
118 | | - |
119 | | - - name: Upload amd64 Windows |
120 | | - if: matrix.os == 'windows' && matrix.arch == 'amd64' |
121 | | - run: | |
122 | | - curl \ |
123 | | - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
124 | | - -H "Content-Type: $(file -b --mime-type $FILE)" \ |
125 | | - --data-binary @$FILE \ |
126 | | - "$UPLOAD_URL?name=$(basename $FILE)" |
127 | | - env: |
128 | | - FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}.exe |
129 | | - |
130 | | - - name: Upload arm64 |
131 | | - if: matrix.os == 'linux' && matrix.arch == 'arm64' |
132 | | - run: | |
133 | | - curl \ |
134 | | - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
135 | | - -H "Content-Type: $(file -b --mime-type $FILE)" \ |
136 | | - --data-binary @$FILE \ |
137 | | - "$UPLOAD_URL?name=$(basename $FILE)" |
138 | | - env: |
139 | | - FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }} |
| 29 | + distribution: goreleaser |
| 30 | + version: ${{ env.GITHUB_REF_NAME }} |
| 31 | + args: release --rm-dist |
| 32 | + env: |
| 33 | + GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }} |
| 34 | + - |
| 35 | + name: Generate SBOM |
| 36 | + uses: anchore/sbom-action@v0 |
| 37 | + with: |
| 38 | + artifact-name: hinge.spdx.json |
| 39 | + path: . |
| 40 | + - |
| 41 | + name: Release SBOM |
| 42 | + uses: anchore/sbom-action/publish-sbom@v0 |
| 43 | + with: |
| 44 | + sbom-artifact-match: ".*\\.spdx.json$" |
140 | 45 |
|
141 | | - - name: Upload arm |
142 | | - if: (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd') && matrix.arch == 'arm' |
143 | | - run: | |
144 | | - curl \ |
145 | | - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
146 | | - -H "Content-Type: $(file -b --mime-type $FILE)" \ |
147 | | - --data-binary @$FILE \ |
148 | | - "$UPLOAD_URL?name=$(basename $FILE)" |
149 | | - env: |
150 | | - FILE: build/hinge-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }} |
0 commit comments