-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (95 loc) · 3.31 KB
/
Copy pathrelease.yml
File metadata and controls
111 lines (95 loc) · 3.31 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026, Timo Pallach (timo@pallach.de).
# Release: push an annotated tag v* (e.g. v0.1.2) to run GoReleaser and publish
# GitHub Release artifacts. Requires GITHUB_TOKEN (default in Actions).
#
# v0.1.0 and v0.1.1 are manual releases (no GoReleaser); skip those tag refs.
name: release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
test:
if: ${{ github.ref != 'refs/tags/v0.1.0' && github.ref != 'refs/tags/v0.1.1' }}
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run unit tests
run: ./bin/run_unit_tests.sh
goreleaser:
needs: test
if: ${{ github.ref != 'refs/tags/v0.1.0' && github.ref != 'refs/tags/v0.1.1' }}
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Install git-cliff
env:
GH_TOKEN: ${{ github.token }}
run: |
CLIFF_VERSION=$(gh api repos/orhun/git-cliff/releases/latest --jq '.tag_name')
curl --silent --show-error --location \
"https://github.com/orhun/git-cliff/releases/download/${CLIFF_VERSION}/git-cliff-${CLIFF_VERSION#v}-x86_64-unknown-linux-musl.tar.gz" \
| tar --extract --gzip --directory /tmp
sudo install --mode=755 \
"$(find /tmp -maxdepth 2 -name git-cliff -type f)" \
/usr/local/bin/git-cliff
git-cliff --version
- name: Generate changelog
run: |
TAG="${GITHUB_REF_NAME}"
PREV_TAG=$(git describe --abbrev=0 --tags "${TAG}^")
echo "Generating changelog from ${PREV_TAG} to ${TAG}"
git-cliff "${PREV_TAG}..${TAG}" --tag "${TAG}" --output /tmp/release-notes.md
echo "--- Changelog content ---"
cat /tmp/release-notes.md
echo "--- End changelog ---"
- name: Install syft
uses: anchore/sbom-action/download-syft@v0
- name: Generate SBOM
run: |
VERSION="${GITHUB_REF_NAME#v}"
syft scan dir:. \
--source-name packer-plugin-sylve \
--source-version "${VERSION}" \
--output cyclonedx-xml=sbom.cdx.xml
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload SBOM to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
gh release upload "${TAG}" \
"sbom.cdx.xml#packer-plugin-sylve_v${VERSION}_sbom.cdx.xml"
- name: Set release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
gh release edit "${TAG}" --notes-file /tmp/release-notes.md