-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (109 loc) · 4.27 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
name: Release
on:
push:
branches:
- semrel
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Define environment variables
run: echo IMAGE_SHA=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ github.sha }} >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build container
uses: docker/build-push-action@v5
with:
file: Dockerfile.test
tags: ${{ env.IMAGE_SHA }}
#push: true
#cache-from: type=registry,ref=user/app:latest
#cache-to: type=inline
outputs: type=docker,dest=/tmp/esi-opticks-${{ github.sha }}.tar
- name: Upload image for next jobs
uses: actions/upload-artifact@v4
with:
name: esi-opticks-${{ github.sha }}
path: /tmp/esi-opticks-${{ github.sha }}.tar
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Define environment variables
run: echo IMAGE_SHA=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ github.sha }} >> $GITHUB_ENV
#- name: Checkout Code
# uses: actions/checkout@v4
##- run: .github/workflows/set_github_env.sh
- name: Download image
uses: actions/download-artifact@v4
with:
name: esi-opticks-${{ github.sha }}
path: /tmp
#- name: Set up Docker buildx
# uses: docker/setup-buildx-action@v3
#- name: Login to GitHub container registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#- name: Build container
# uses: docker/build-push-action@v5
# with:
# file: Dockerfile.test
# tags: ${{ env.IMAGE_SHA }}
# pull: true
# load: true
# cache-from: type=registry,ref=${{ env.IMAGE_SHA }}
- name: Run tests
run: |
docker load --input /tmp/esi-opticks-${{ github.sha }}.tar
docker run ${{ env.IMAGE_SHA }} curl --version
release:
runs-on: ubuntu-latest
needs: test
steps:
- name: Define environment variables
run: echo IMAGE_SHA=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ github.sha }} >> $GITHUB_ENV
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Important for Semantic Release to analyze all commits
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#- name: Release image
# run: |
# docker load --input /tmp/esi-opticks-${{ github.sha }}.tar
# docker tag ghcr.io/${{ github.repository_owner }}/esi-opticks:${{ github.sha }} ghcr.io/${{ github.repository_owner }}/esi-opticks:latest
# docker tag ghcr.io/${{ github.repository_owner }}/esi-opticks:${{ github.sha }} ghcr.io/${{ github.repository_owner }}/esi-opticks:latest
# ${{ steps.semantic.outputs.new_release_version }}
# docker push ghcr.io/${{ github.repository_owner }}/esi-opticks:${{ github.sha }}
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.semantic.outputs.new_release_git_tag }}
- name: Download image
uses: actions/download-artifact@v4
with:
name: esi-opticks-${{ github.sha }}
path: /tmp
- name: Load Image
run: docker load --input /tmp/esi-opticks-${{ github.sha }}.tar
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build container
uses: docker/build-push-action@v5
with:
file: Dockerfile.test
tags: |
ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ steps.semantic.outputs.new_release_version }}
ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):latest
push: true
cache-from: type=registry,ref=${{ env.IMAGE_SHA }}
#cache-to: type=inline
#outputs: type=docker,dest=/tmp/esi-opticks-${{ github.sha }}.tar