Skip to content

Commit 556cdc8

Browse files
committed
Make release and docker workflows
1 parent e619a35 commit 556cdc8

File tree

2 files changed

+66
-50
lines changed

2 files changed

+66
-50
lines changed

.github/workflows/docker.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Upload Docker images to ghcr.io
2+
on:
3+
release:
4+
types: [published]
5+
workflow_dispatch:
6+
inputs:
7+
ref:
8+
description: 'Git tag to push the image'
9+
required: true
10+
type: string
11+
jobs:
12+
docker:
13+
name: Build image
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v4
18+
with:
19+
ref: ${{ inputs.ref }}
20+
- name: Docker meta
21+
id: meta
22+
uses: docker/metadata-action@v5
23+
with:
24+
context: ${{ inputs.ref && 'git' || 'workflow' }}
25+
images: ghcr.io/${{ github.repository }}
26+
# create latest tag for branch events
27+
flavor: |
28+
latest=${{ inputs.ref && 'false' || 'auto' }}
29+
tags: |
30+
type=semver,pattern={{version}},value=${{inputs.ref}}
31+
type=semver,pattern={{major}}.{{minor}},value=${{inputs.ref}}
32+
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{inputs.ref}}
33+
- name: Login to ghcr.io
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Build and push
40+
id: docker_build
41+
uses: docker/build-push-action@v5
42+
with:
43+
# push for non-pr events
44+
push: ${{ github.event_name != 'pull_request' }}
45+
context: .
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/upload-assets.yml

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,43 @@ name: Upload Packages to new release
55
release:
66
types:
77
- published
8+
workflow_dispatch:
9+
inputs:
10+
ref:
11+
description: 'Git tag to push the image'
12+
required: true
13+
type: string
814

915
jobs:
1016
build:
1117
name: Build
1218
runs-on: ubuntu-latest
1319

14-
outputs:
15-
deb: ${{ steps.build.outputs.deb }}
16-
rpm: ${{ steps.build.outputs.rpm }}
17-
sha256sum: ${{ steps.build.outputs.sha256sum }}
18-
md5sum: ${{ steps.build.outputs.md5sum }}
19-
2020
steps:
2121
- uses: actions/checkout@v4
2222
name: Checkout
2323
with:
2424
# Otherwise there's a risk to not get latest tag
2525
# We hope, that the current commit at
26-
# least 50 commits close to the latest release
27-
fetch-depth: 50
26+
# least 100 commits close to the latest release
27+
fetch-depth: 100
28+
ref: ${{ inputs.ref }}
2829
- name: Build packages
2930
id: build
3031
run: |
3132
# Checkout action doesn't fetch tags
3233
git fetch --tags
3334
make -e CGO_ENABLED=0 packages
34-
make github_artifact
35-
- name: Upload rpm
36-
id: upload-rpm
37-
uses: actions/upload-release-asset@v1
38-
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
ASSET: ${{ steps.build.outputs.rpm }}
41-
with:
42-
upload_url: ${{ github.event.release.upload_url }}
43-
asset_path: artifact/${{ env.ASSET }}
44-
asset_name: ${{ env.ASSET }}
45-
asset_content_type: application/octet-stream
46-
- name: Upload sha256sum
47-
id: upload-sha256sum
48-
uses: actions/upload-release-asset@v1
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
ASSET: ${{ steps.build.outputs.sha256sum }}
52-
with:
53-
upload_url: ${{ github.event.release.upload_url }}
54-
asset_path: artifact/${{ env.ASSET }}
55-
asset_name: ${{ env.ASSET }}
56-
asset_content_type: application/octet-stream
57-
- name: Upload md5sum
58-
id: upload-md5sum
59-
uses: actions/upload-release-asset@v1
35+
- name: Upload release assets
6036
env:
6137
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
ASSET: ${{ steps.build.outputs.md5sum }}
63-
with:
64-
upload_url: ${{ github.event.release.upload_url }}
65-
asset_path: artifact/${{ env.ASSET }}
66-
asset_name: ${{ env.ASSET }}
67-
asset_content_type: application/octet-stream
68-
- name: Upload deb
69-
id: upload-deb
70-
uses: actions/upload-release-asset@v1
38+
run: |
39+
TAG="${{ inputs.ref && inputs.ref || github.event.release.tag_name }}"
40+
gh release upload --repo ${{ github.repository }} "$TAG" \
41+
out/*.deb out/*.rpm out/*sum
42+
- name: Upload packages to packagecloud.com
7143
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73-
ASSET: ${{ steps.build.outputs.deb }}
74-
with:
75-
upload_url: ${{ github.event.release.upload_url }}
76-
asset_path: artifact/${{ env.ASSET }}
77-
asset_name: ${{ env.ASSET }}
78-
asset_content_type: application/octet-stream
44+
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
45+
run: |
46+
go install github.com/mlafeldt/pkgcloud/cmd/pkgcloud-push
47+
make packagecloud-stable

0 commit comments

Comments
 (0)