Skip to content

Commit 007fc3a

Browse files
committed
ci: improve GitHub actions workflows
* execute integration tests * publish artifacts from GH workflow * sign docker images * sign binaries
1 parent 023c8d3 commit 007fc3a

File tree

4 files changed

+131
-64
lines changed

4 files changed

+131
-64
lines changed

.github/workflows/main.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Release
2+
on:
3+
workflow_run:
4+
workflows: ["Tests"]
5+
branches: ["master", "main"]
6+
types:
7+
- completed
8+
permissions:
9+
contents: write
10+
jobs:
11+
version:
12+
name: Gather version information
13+
runs-on: ubuntu-latest
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
outputs:
16+
latest_version: ${{ steps.latest_version.outputs.version }}
17+
next_version: ${{ steps.next_version.outputs.version }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- name: Latest version
23+
id: latest_version
24+
uses: PSanetra/git-semver-actions/latest@master
25+
- name: Next version
26+
id: next_version
27+
uses: PSanetra/git-semver-actions/next@master
28+
draft_release:
29+
name: Release
30+
needs: version
31+
if: ${{ needs.version.outputs.latest_version != needs.version.outputs.next_version }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
- name: Generate Changelog
38+
id: generate_changelog
39+
uses: PSanetra/git-semver-actions/markdown-log@master
40+
- name: Create Release
41+
id: create_release
42+
uses: actions/create-release@v1
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
with:
46+
tag_name: v${{ needs.version.outputs.next_version }}
47+
release_name: Release ${{ needs.version.outputs.next_version }}
48+
body: |
49+
${{ steps.generate_changelog.outputs.changelog }}
50+
draft: false # Tag must be published before gitreleaser is executed
51+
prerelease: false
52+
build_and_publish_artifacts:
53+
name: Build and publish artifacts
54+
needs: [version, draft_release]
55+
if: ${{ needs.version.outputs.latest_version != needs.version.outputs.next_version }}
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0
61+
- uses: sigstore/cosign-installer@v3
62+
- name: Login cosign to Docker Hub
63+
run: |
64+
echo '${{ secrets.DOCKER_PASSWORD }}' | cosign login ${{ vars.DOCKER_REGISTRY }} --username '${{ vars.DOCKER_USERNAME }}' --password-stdin
65+
- uses: anchore/sbom-action/[email protected]
66+
- uses: docker/setup-qemu-action@v3
67+
- uses: docker/setup-buildx-action@v3
68+
- name: Run GoReleaser
69+
uses: goreleaser/goreleaser-action@v6
70+
with:
71+
distribution: goreleaser
72+
version: '~> v2'
73+
args: release --clean
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches: ["master", "main"]
5+
pull_request:
6+
branches: ["master", "main"]
7+
jobs:
8+
unit_tests:
9+
name: Unit Tests
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-go@v5
14+
with:
15+
go-version: '^1.24.1'
16+
- run: go test ./...
17+
integration_tests:
18+
name: Integration Tests
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Setup Java
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '21'
26+
distribution: 'temurin'
27+
cache: 'maven'
28+
- name: Run Tests
29+
run: cd integration_tests && mvn verify

.goreleaser.yaml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1+
version: 2
12
project_name: git-semver
2-
before:
3-
hooks:
4-
# You may remove this if you don't use go modules.
5-
- go mod tidy
6-
# you may remove this if you don't need go generate
7-
- go generate ./...
83
builds:
94
- main: ./cli/main.go
105
goos:
@@ -19,17 +14,8 @@ builds:
1914
ignore:
2015
- goos: windows
2116
goarch: arm64
22-
checksum:
23-
name_template: 'checksums.txt'
2417
snapshot:
2518
name_template: "{{ incpatch .Version }}-next"
26-
changelog:
27-
skip: true
28-
release:
29-
github:
30-
owner: PSanetra
31-
name: git-semver
32-
mode: keep-existing
3319
dockers:
3420
- image_templates:
3521
- "psanetra/git-semver:latest"
@@ -41,7 +27,32 @@ dockers:
4127
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
4228
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
4329
- "--label=org.opencontainers.image.version={{ .Version }}"
44-
30+
docker_signs:
31+
- cmd: cosign
32+
artifacts: all
33+
args:
34+
- "sign"
35+
- "${artifact}"
36+
- "--yes"
37+
checksum:
38+
name_template: 'checksums.txt'
39+
signs:
40+
- cmd: cosign
41+
certificate: "${artifact}.pem"
42+
artifacts: checksum
43+
args:
44+
- "sign-blob"
45+
- "--output-certificate=${certificate}"
46+
- "--output-signature=${signature}"
47+
- "${artifact}"
48+
- "--yes"
49+
changelog:
50+
disable: true
51+
release:
52+
github:
53+
owner: PSanetra
54+
name: git-semver
55+
mode: keep-existing
4556
# modelines, feel free to remove those if you don't want/use them:
4657
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
4758
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

0 commit comments

Comments
 (0)