-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (115 loc) · 3.75 KB
/
Copy pathbuild.yml
File metadata and controls
128 lines (115 loc) · 3.75 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Build and publish
on:
push:
tags: ['v*']
pull_request:
workflow_dispatch:
inputs:
push:
description: 'Push'
required: false
type: boolean
default: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: diff2rss
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
outputs:
OUTPUT_ARTIFACT_NAME: image-archive
OUTPUT_FILE: diff2rss-${{ github.ref_name }}.oci.tar
steps:
- uses: actions/checkout@v6
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=tag
type=ref,event=pr
- name: Build and push image
uses: docker/build-push-action@v7
with:
push: ${{ inputs.push != false }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
platforms: linux/amd64,linux/arm64
cache-from: |
type=gha
type=gha,scope=main
cache-to: type=gha,mode=max
provenance: false
# Only for tag builds: produce a release artifact (OCI archive) and upload it
- name: Export OCI archive (tag builds only)
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v7
with:
push: false
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
provenance: false
outputs: type=oci,dest=/tmp/diff2rss-${{ github.ref_name }}.oci.tar
- name: Upload image archive artifact (tag builds only)
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v6
with:
name: image-archive
path: /tmp/diff2rss-${{ github.ref_name }}.oci.tar
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Download build artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/download-artifact@v7
with:
name: ${{ needs.build.outputs.OUTPUT_ARTIFACT_NAME }}
path: .
- name: Parse tags
id: parse_tags
run: |
git fetch --tags
echo "tag_count=$(git tag -l | wc -l)" >> $GITHUB_OUTPUT
- name: Update CHANGELOG
continue-on-error: ${{ steps.parse_tags.outputs.tag_count == '1' }}
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}
artifacts: ${{ needs.build.outputs.OUTPUT_FILE }}
- name: Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: main
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }}'
file_pattern: CHANGELOG.md