-
-
Notifications
You must be signed in to change notification settings - Fork 85
103 lines (101 loc) · 3.24 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
name: Release
on:
push:
tags:
- 'v*'
jobs:
test:
name: Test Elixir ${{ matrix.version }}
runs-on: ubuntu-latest
container: elixir:${{ matrix.version }}-alpine
strategy:
matrix:
include:
- version: "1.14"
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MIX_ENV: test
DB_URL: postgres://postgres:postgres@postgres/keila
steps:
- name: install system packages
run: apk add build-base git tar
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
_build
deps
assets/node_modules
key: keila-${{ runner.os }}-elixir-${{ matrix.version }}-${{ hashFiles('mix.lock') }}
- name: mix deps.get
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: mix format --check-formatted
run: mix format --check-formatted
- name: mix ecto.create && ecto.migrate
run: |
mix ecto.create
mix ecto.migrate
- name: mix test
run: mix test
build:
name: Build and Release
needs:
- test
runs-on: ubuntu-latest
environment: build
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- id: meta
run: |
VERSION=`echo ${{ github.ref }} | grep -oE "([0-9]+)\.([0-9]+)\.([0-9]+)"`
MINOR_VERSION=`echo $VERSION | grep -oE "^([0-9]+)\.([0-9]+)"`
MAJOR_VERSION=`echo $VERSION | grep -oE "^([0-9]+)"`
echo "::set-output name=version::${VERSION}"
echo "::set-output name=minor_version::${MINOR_VERSION}"
echo "::set-output name=major_version::${MAJOR_VERSION}"
awk -v version="${VERSION}" '/## Version\s/ {printit = $3 == version}; printit;' "$2" CHANGELOG.md > __CHANGELOG__.md
cat __CHANGELOG__.md
- uses: docker/build-push-action@v3
with:
context: .
file: ./ops/Dockerfile
tags: |
pentacent/keila:latest
pentacent/keila:${{ steps.meta.outputs.version }}
pentacent/keila:${{ steps.meta.outputs.major_version }}
pentacent/keila:${{ steps.meta.outputs.minor_version }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.meta.outputs.version }}
body_path: __CHANGELOG__.md
release_name: Keila v${{ steps.meta.outputs.version }}
draft: false
prerelease: false