-
Notifications
You must be signed in to change notification settings - Fork 60
145 lines (125 loc) · 5.87 KB
/
release.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Release
on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
# Publish `v1.2.3` tags as releases.
tags:
- v*
env:
PODMAN_IMAGE: podman
PODMAN_MINIMAL_IMAGE: podman-minimal
PODMAN_REMOTE_IMAGE: podman-remote
jobs:
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up qemu
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Build & test
run: make images test
- name: Build signed archives
run: make clean multiarch-tar TAR_TARGET=signed-tar
env:
GPG_SIGN_KEY: ${{ secrets.GPG_SIGN_KEY }}
GPG_SIGN_KEY_PASSPHRASE: ${{ secrets.GPG_SIGN_KEY_PASSPHRASE }}
- name: Log into GitHub registry
run: echo "$GITHUB_TOKEN" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Log into DockerHub registry
run: echo "$DOCKERHUB_TOKEN" | docker login docker.io -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push images
run: |
set -eu
GITHUB_IMAGE_REPO=ghcr.io/mgoltzsche/podman
GITHUB_IMAGE_REPO=$(echo $GITHUB_IMAGE_REPO | tr '[A-Z]' '[a-z]')
DOCKERHUB_IMAGE_REPO=docker.io/mgoltzsche/podman
# Strip git ref prefix from version
TAGS=$(echo "$GITHUB_REF" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "$GITHUB_REF" == "refs/tags/v"* ]] && TAGS=$(echo $TAGS | sed -e 's/^v//')
# Expand tags: 1.2.3 -> 1 1.2 1.2.3
TAGS="$(echo "$TAGS" | sed -E -e 's/^((([0-9]+)\.[0-9]+)\.[0-9]+)$/\3 \2 \1/')"
for IMAGE in $PODMAN_REMOTE_IMAGE $PODMAN_IMAGE $PODMAN_MINIMAL_IMAGE; do
TAG_SUFFIX=$(echo $IMAGE | sed -E -e 's/^([^-]+)//')
LATEST_TAG="$([ "$TAG_SUFFIX" ] && echo $TAG_SUFFIX | sed -E -e 's/^-//' || echo latest)"
[ "$TAGS" == "master" ] && IMAGE_TAGS="$LATEST_TAG" || IMAGE_TAGS="$LATEST_TAG $TAGS"
TAG_OPTS=
printf 'Pushing image tags: '
for TAG in $IMAGE_TAGS; do
[ "$TAG" = "$LATEST_TAG" ] || TAG="${TAG}${TAG_SUFFIX}"
TAG_OPTS="$TAG_OPTS -t $DOCKERHUB_IMAGE_REPO:$TAG -t $GITHUB_IMAGE_REPO:$TAG"
printf ' %s' "$TAG"
done
echo
echo "Pushing $IMAGE image to $DOCKERHUB_IMAGE_REPO and $GITHUB_IMAGE_REPO"
make "$IMAGE" PODMAN_BUILD_OPTS="$TAG_OPTS" PODMAN_MINIMAL_BUILD_OPTS="$TAG_OPTS" PODMAN_REMOTE_BUILD_OPTS="$TAG_OPTS"
done
env:
BUILDX_OUTPUT: type=registry
PLATFORM: linux/arm64/v8,linux/amd64
GITHUB_REF: ${{ github.ref }}
- name: Create release
if: github.ref != 'refs/heads/master'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: true
- name: Upload arm64 archive signature
if: github.ref != 'refs/heads/master'
id: upload-arm64-archive-signature
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./build/asset/podman-linux-arm64.tar.gz.asc
asset_name: podman-linux-arm64.tar.gz.asc
asset_content_type: application/octet-stream
- name: Upload arm64 archive
if: github.ref != 'refs/heads/master'
id: upload-arm64-archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./build/asset/podman-linux-arm64.tar.gz
asset_name: podman-linux-arm64.tar.gz
asset_content_type: application/octet-stream
- name: Upload amd64 archive signature
if: github.ref != 'refs/heads/master'
id: upload-amd64-archive-signature
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./build/asset/podman-linux-amd64.tar.gz.asc
asset_name: podman-linux-amd64.tar.gz.asc
asset_content_type: application/octet-stream
- name: Upload amd64 archive
if: github.ref != 'refs/heads/master'
id: upload-amd64-archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./build/asset/podman-linux-amd64.tar.gz
asset_name: podman-linux-amd64.tar.gz
asset_content_type: application/octet-stream