-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (140 loc) · 4.17 KB
/
test-and-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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: test-and-release
on:
push:
branches:
- 2.x
- main
- alpha
- beta
- next
- next-major
jobs:
tests:
name: Run tests (Elixir ${{matrix.elixir}}, OTP ${{matrix.otp}})
strategy:
matrix:
include:
- elixir: 1.13
otp: 24
lint: lint
- elixir: 1.14
otp: 25
lint: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-elixir@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
- name: Restore deps and _build cache
uses: actions/cache@v3
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}
- name: Install dependencies
run: mix deps.get --only test
env:
MIX_ENV: test
- name: Check source code format
run: mix format --check-formatted
if: ${{ matrix.lint }}
env:
MIX_ENV: test
- name: Remove compiled application files
run: mix clean
- name: Compile dependencies
run: mix compile
if: ${{ !matrix.lint }}
env:
MIX_ENV: test
- name: Compile & lint dependencies
run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}
env:
MIX_ENV: test
- name: Run tests
run: mix test
env:
MIX_ENV: test
release:
name: semantic release
runs-on: ubuntu-latest
needs: [ tests ]
outputs:
version: ${{ steps.semantic.outputs.new_release_version }}
channel: ${{ steps.semantic.outputs.new_release_channel }}
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
- name: 💊 Setup Elixir
uses: erlef/setup-beam@v1
with:
otp-version: '25'
elixir-version: '1.14.0'
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v3
id: semantic
with:
semantic_version: 19
extra_plugins: |
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
working_directory: apps/phoenix_duskmoon
env:
MIX_ENV: prod
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
build-demo:
name: Build demo
runs-on: ubuntu-latest
needs: [ release ]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWD }}
-
name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: true
build-args: |
RELEASE_VERSION=${{ needs.release.outputs.version }}
tags: |
docker.io/gsmlg/duskmoon-storybook:v${{ needs.release.outputs.version }}
docker.io/gsmlg/duskmoon-storybook:${{ needs.release.outputs.channel || 'latest' }}
ghcr.io/gsmlg-dev/duskmoon-storybook:v${{ needs.release.outputs.version }}
ghcr.io/gsmlg-dev/duskmoon-storybook:${{ needs.release.outputs.channel || 'latest' }}