-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (92 loc) · 2.91 KB
/
build.yml
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
name: Build and Push
on:
workflow_dispatch:
push:
paths-ignore:
- "action.yml"
- "README.md"
- "website/**"
permissions:
packages: write
contents: write
jobs:
generate-version:
runs-on: ubuntu-latest
outputs:
trunkver: ${{ steps.trunkver.outputs.trunkver }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate trunkver
id: trunkver
uses: crftd-tech/trunkver@main
with:
baseVersion: "1.0.0"
prerelease: "true"
build-release:
runs-on: ubuntu-latest
needs: [generate-version]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Build trunkver
env:
VERSION: ${{ needs.generate-version.outputs.trunkver }}
run: |
(
unset GITHUB_SHA
unset GITHUB_RUN_ID
make test all spec "VERSION=${VERSION}"
)
- name: Create release
id: release
uses: softprops/action-gh-release@v2
if: github.ref == 'refs/heads/main'
with:
name: ${{ needs.generate-version.outputs.trunkver }}
tag_name: ${{ needs.generate-version.outputs.trunkver }}
files: |
out/trunkver*
build-docker:
runs-on: ubuntu-latest
needs: [generate-version]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/crftd-tech/trunkver
tags: |
type=raw,value=${{ needs.generate-version.outputs.trunkver }}
type=raw,value=latest
- name: Log in to the Container registry
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@7e094594beda23fc8f21fa31049f4b203e51096b
with:
context: .
push: ${{ github.ref == 'refs/heads/main' }}
build-args: |
VERSION=${{ needs.generate-version.outputs.trunkver }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update the action.yml with the new image tag
if: github.ref == 'refs/heads/main'
run: |
yq eval --inplace '.runs.image = "docker://ghcr.io/crftd-tech/trunkver:${{ needs.generate-version.outputs.trunkver }}"' action.yml
git config --global user.email "bot@crftd.tech"
git config --global user.name "crftd-bot"
git add action.yml
git commit -m "chore: Bump image tag in action.yml"
git pull origin --rebase
git push origin