-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (211 loc) · 7.91 KB
/
create-publish-docker.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: Create Docker image and publish to GH Packages
on:
push:
branches: [ main ] # create a new version whenever we push to main
schedule:
- cron: "12 2 2 * *" # run at 2:12 of the 2nd of every month
env:
DOCKER_REGISTRY: ghcr.io # where to register the image
REPO_PATH: github.com/furrer-lab/abn.git
# REPO_PATH: github.com:furrer-lab/abn.git # for private repo cloned via ssh
# Set the path to the package where the DESCRIPTION file can be found
PACKAGE_PATH: ${{ vars.PACKAGE_PATH || './' }}
JAGS: JAGS-4.3.2
# this if for the valgrind container only
DRMEMORY: "2.6.0"
CHGLOG_RELEASE: git-chglog_0.15.4_linux_amd64
CHGLOG_PATH: https://github.com/git-chglog/git-chglog/releases/download/v0.15.4
jobs:
increment-tag:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
VERSION: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Auto increment calver version
uses: reecetech/version-increment@2023.10.1
id: version
with:
scheme: calver
build-and-push:
runs-on: ubuntu-latest
needs: increment-tag
env:
CUSTOM_TAG: "${{ needs.increment-tag.outputs.VERSION }}"
permissions: # for `GITHUB_TOKEN`
contents: read
packages: write
strategy:
fail-fast: false
matrix:
# NOTE: valgrind container is fedora, gcc, devel
# see https://r-hub.github.io/containers/containers.html#valgrind
target-os: ['debian', 'fedora']
compiler: ['gcc', 'clang']
r-version: ['devel', 'release', 'patched']
exclude:
- target-os: 'fedora'
r-version: 'release'
- target-os: 'fedora'
r-version: 'patched'
- compiler: 'clang'
r-version: 'patched'
- compiler: 'clang'
r-version: 'release'
include:
- target-os: 'valgrind'
compiler: 'gcc'
r-version: 'devel'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags and labels
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
# TODO: set a proper name of the image (same as in context below)
images: ${{ env.DOCKER_REGISTRY}}/${{ format('{0}/{1}/{2}/{3}/abn', github.repository, matrix.target-os, matrix.compiler, matrix.r-version ) }}
tags: | # set Docker tags to git tags
type=raw,value=${{ env.CUSTOM_TAG }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
# For private repo cloned via ssh we need a deploy key
# - name: Write the ssh key file
# run: |
# echo "${{ secrets.DEVEL_ABN_DEPLOY }}" >> ssh_key
# shell: bash
- name: Build and push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: ${{ format('./containers/{0}/', matrix.target-os ) }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TARGET_OS=${{ matrix.target-os }}
COMPILER=${{ matrix.compiler }}
R_VERSION=${{ matrix.r-version }}
PACKAGE_PATH=${{ env.PACKAGE_PATH}}
REPO_PATH=${{ env.REPO_PATH }}
JAGS=${{ env.JAGS }}
DRMEMORY=${{ env.DRMEMORY }}
# For private repo cloned via ssh
# secret-files: |
# key=./ssh_key
container-integrity-and-config:
runs-on: ubuntu-22.04
needs: [ 'increment-tag', 'build-and-push']
permissions:
contents: write
packages: read
container:
image: ${{ vars.CONTAINER_SOURCE }}/${{ matrix.target-os }}/${{ matrix.compiler }}/${{ matrix.r-version }}/abn:${{ needs.increment-tag.outputs.VERSION }}
options: --user 1001
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
target-os: ['debian', 'fedora']
compiler: ['gcc', 'clang']
r-version: ['devel', 'release', 'patched']
exclude:
- target-os: 'fedora'
r-version: 'release'
- target-os: 'fedora'
r-version: 'patched'
- compiler: 'clang'
r-version: 'patched'
- compiler: 'clang'
r-version: 'release'
include:
- target-os: 'valgrind'
compiler: 'gcc'
r-version: 'devel'
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Install knitr
run: |
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
.libPaths(Sys.getenv("R_LIBS_USER"))
install.packages("knitr")
shell: Rscript {0}
- name: Write out configuration
run: |
Rscript -e 'args<-commandArgs(TRUE);knitr::knit_hooks$set(output = function(x, options){gsub("##", ">\n> ", x)});knitr::knit("src/release_info.tpl", sprintf("info/%s-%s-%s-%s.md", args[1], args[2], args[3], args[4]))' ${{ matrix.target-os}} ${{ matrix.compiler }} ${{ matrix.r-version }} abn
- name: Save config as artifact
uses: actions/upload-artifact@v4
with:
name: info-artifact-${{ matrix.target-os }}_${{ matrix.compiler }}_${{ matrix.r-version }}
path: info/${{ matrix.target-os }}-${{ matrix.compiler }}-${{ matrix.r-version }}-abn.md
update-container-info:
runs-on: ubuntu-latest
needs: [ 'increment-tag', 'container-integrity-and-config' ]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Getting artifacts
uses: actions/download-artifact@v4
with:
pattern: "info-artifact-*"
path: info/
merge-multiple: true
- name: Update the archive
run: |
mkdir -p info/archive/${{ needs.increment-tag.outputs.VERSION }}
cp info/*.md info/archive/${{ needs.increment-tag.outputs.VERSION }}/
- name: Commit config for container
uses: EndBug/add-and-commit@v9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
pull: '--rebase --autostash'
push: true
default_author: github_actions
message: "auto-update: container info for release ${{ needs.increment-tag.outputs.VERSION }}"
add: "info/"
auto-update-and-publish-tag:
runs-on: ubuntu-latest
needs: [ 'increment-tag', 'update-container-info']
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Get git-chglog and update CHANGELOG
run: |
wget ${{ env.CHGLOG_PATH }}/${{ env.CHGLOG_RELEASE}}.tar.gz # get the binary for the chglog
tar --extract --file=${{ env.CHGLOG_RELEASE}}.tar.gz git-chglog
git config user.email "actions@github.com"
git config user.name "github_actions"
git tag -a ${{ needs.increment-tag.outputs.VERSION }} -m 'interim tag for changelog'
./git-chglog -o CHANGELOG.md # update the changelog file
git tag -d ${{ needs.increment-tag.outputs.VERSION }} # remove the tag again
- name: Commit CHANGELOG.md update
uses: EndBug/add-and-commit@v9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
pull: '--rebase --autostash'
default_author: github_actions
message: "auto-update: CHANGELOG.md"
add: 'CHANGELOG.md'
tag: "${{ needs.increment-tag.outputs.VERSION }}"