Skip to content

Commit a9d57f2

Browse files
authored
Merge pull request #1 from deeagle/dev/add-semantic-release
ci: add basic ci and release workflows
2 parents 1cea3f4 + df8ad47 commit a9d57f2

File tree

8 files changed

+189
-0
lines changed

8 files changed

+189
-0
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint-readme:
11+
name: Lint readme file
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v2
16+
17+
- name: Lint readme file
18+
uses: avto-dev/markdown-lint@v1
19+
with:
20+
#rules: '/lint/rules/changelog.js'
21+
#config: '/lint/config/changelog.yml'
22+
args: 'README.md'
23+
24+
lint-dockerfile:
25+
name: Lint Dockerfile
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@main
30+
- name: Lint dockerfile
31+
uses: hadolint/[email protected]
32+
with:
33+
dockerfile: Dockerfile

.github/workflows/release-tst.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release test
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the main branch
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
# Only for testing of the release environment.
13+
semantic:
14+
name: Semantic-Release-Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@main
19+
20+
- name: Setup Nodejs
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: "16"
24+
25+
- name: Install dependencies
26+
run: npm install @semantic-release/changelog @semantic-release/git @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/exec @semantic-release/git semantic-release/release-notes-generator
27+
28+
- name: Release (Dry-Run)
29+
run: npx semantic-release -d
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release version
2+
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
outputs:
14+
app_version: ${{ steps.step1.outputs.app_version }}
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@main
18+
19+
- name: Setup Nodejs
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: '16'
23+
24+
- name: Install dependencies
25+
run: npm install @semantic-release/changelog @semantic-release/git @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/exec @semantic-release/git semantic-release/release-notes-generator
26+
27+
- name: Release
28+
run: npx semantic-release
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Get the last tag via git and store in var
33+
id: step1
34+
run: |
35+
APP_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
36+
echo "${APP_VERSION}"
37+
echo "::set-output name=app_version::${APP_VERSION}"
38+
39+
docker-hub:
40+
needs: release
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@main
46+
47+
- name: show app_version from release job
48+
run: echo ${{ needs.release.outputs.app_version }}
49+
50+
- name: Login to DockerHub
51+
uses: docker/login-action@v1
52+
with:
53+
username: ${{ secrets.DOCKER_USERNAME }}
54+
password: ${{ secrets.DOCKER_TOKEN }}
55+
56+
- name: Extract metadata (tags, labels) for Docker
57+
id: meta
58+
uses: docker/metadata-action@v3
59+
with:
60+
images: docdee/semantic-release-gitea
61+
tags: |
62+
type=ref,event=branch
63+
type=raw,value=${{ needs.release.outputs.app_version }}
64+
type=raw,value=latest
65+
66+
- name: Build and push
67+
uses: docker/build-push-action@v2
68+
with:
69+
context: .
70+
file: ./Dockerfile
71+
push: true
72+
tags: ${{ steps.meta.outputs.tags }}
73+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

.hadolint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Hadolint configuration file
2+
3+
# configure ignore rules
4+
# see https://github.com/hadolint/hadolint#rules for a list of available rules.
5+
ignored:
6+
- DL3018

.releaserc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"branch": "main",
3+
"debug": "true",
4+
"plugins": [
5+
"@semantic-release/commit-analyzer",
6+
"@semantic-release/release-notes-generator",
7+
[
8+
"@semantic-release/changelog",
9+
{
10+
"changelogFile": "CHANGELOG.md",
11+
"changelogTitle": "# Semantic Versioning Changelog"
12+
}
13+
],
14+
[
15+
"@semantic-release/exec",
16+
{
17+
"prepareCmd": "echo ${nextRelease.version}"
18+
}
19+
],
20+
[
21+
"@semantic-release/git",
22+
{
23+
"assets": [
24+
"CHANGELOG.md"
25+
]
26+
}
27+
],
28+
[
29+
"@semantic-release/github",
30+
{
31+
"assets": [
32+
{
33+
"path": "dist/**"
34+
}
35+
]
36+
}
37+
]
38+
]
39+
}

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM alpine:3

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# semantic-release-gitea-container
2+
3+
![Build status](https://github.com/deeagle/ansible-lint/workflows/CI/badge.svg)
4+
[![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg)
5+
[![Alpine](https://img.shields.io/badge/Alpine_Linux-0D597F?style=flat-square&logo=alpine-linux&logoColor=white)](https://img.shields.io/badge/Alpine_Linux-0D597F?style=flat-square&logo=alpine-linux&logoColor=white)
6+
27
Container includes semantic-release to gitea for CI

0 commit comments

Comments
 (0)