Skip to content

Commit b58d5eb

Browse files
sh1luohsluoyz
authored andcommitted
feat: support semantic release (casdoor#244)
Signed-off-by: sh1luo <[email protected]>
1 parent 8c6f0a3 commit b58d5eb

File tree

8 files changed

+188
-34
lines changed

8 files changed

+188
-34
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web/node_modules/

.github/semantic.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Always validate the PR title AND all the commits
2+
titleAndCommits: true
3+
# Require at least one commit to be valid
4+
# this is only relevant when using commitsOnly: true or titleAndCommits: true,
5+
# which validate all commits by default
6+
anyCommit: true
7+
# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns")
8+
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
9+
allowMergeCommits: false
10+
# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"")
11+
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
12+
allowRevertCommits: false

.github/workflows/build.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
pull_request:
8+
branches:
9+
- "*"
10+
11+
jobs:
12+
frontend:
13+
name: Front-end build
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-node@v2
18+
with:
19+
node-version: '14.17.0'
20+
- run: yarn install && CI=false yarn run build
21+
working-directory: ./web
22+
23+
backend:
24+
name: Back-end build
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: actions/setup-go@v2
29+
with:
30+
go-version: '^1.16.5'
31+
- run: go version
32+
33+
- name: Build
34+
run: |
35+
go build -race -ldflags "-extldflags '-static'"
36+
working-directory: ./
37+
38+
docker:
39+
name: Docker compose
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v2
44+
- name: Start containers
45+
run: docker-compose up

.github/workflows/release.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
frontend:
7+
name: Front-end build
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v2
12+
with:
13+
node-version: '14.17.0'
14+
- run: yarn install && CI=false yarn run build
15+
working-directory: ./web
16+
17+
backend:
18+
name: Back-end build
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: actions/setup-go@v2
23+
with:
24+
go-version: '^1.16.5'
25+
26+
- name: Build
27+
run: |
28+
go build -race -ldflags "-extldflags '-static'"
29+
working-directory: ./
30+
31+
release:
32+
name: Release
33+
runs-on: ubuntu-latest
34+
needs: [frontend, backend]
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v2
42+
with:
43+
node-version: 12
44+
- name: Release
45+
run: yarn global add [email protected] && semantic-release
46+
env:
47+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
48+
49+
publish:
50+
name: Publish
51+
runs-on: ubuntu-latest
52+
needs: release
53+
steps:
54+
- name: Check out the repo
55+
uses: actions/checkout@v2
56+
- name: Log in to Docker Hub
57+
uses: docker/login-action@v1
58+
with:
59+
username: ${{ secrets.DOCKERHUB_USERNAME }}
60+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
61+
- name: Push to Docker Hub
62+
uses: docker/build-push-action@v2
63+
with:
64+
push: true
65+
tags: shiluo/casdoor:latest

.releaserc.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"debug": true,
3+
"branches": [
4+
"+([0-9])?(.{+([0-9]),x}).x",
5+
{
6+
"name": "rc"
7+
},
8+
{
9+
"name": "beta",
10+
"prerelease": true
11+
},
12+
{
13+
"name": "alpha",
14+
"prerelease": true
15+
}
16+
],
17+
"plugins": [
18+
"@semantic-release/commit-analyzer",
19+
"@semantic-release/release-notes-generator",
20+
"@semantic-release/github"
21+
]
22+
}

Dockerfile

+19-25
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
FROM golang:1.17-rc-buster
2-
WORKDIR /casdoor
3-
COPY ./ /casdoor
4-
RUN go env -w CGO_ENABLED=0 GOPROXY=https://goproxy.io,direct GOOS=linux GOARCH=amd64 \
5-
&& apt update && apt install sudo \
6-
&& wget https://nodejs.org/dist/v12.22.0/node-v12.22.0-linux-x64.tar.gz \
7-
&& sudo tar xf node-v12.22.0-linux-x64.tar.gz \
8-
&& sudo apt install wait-for-it
9-
ENV PATH=$PATH:/casdoor/node-v12.22.0-linux-x64/bin
10-
RUN npm install -g yarn \
11-
&& cd web \
12-
&& yarn install \
13-
&& yarn run build \
14-
&& rm -rf node_modules \
15-
&& cd /casdoor \
16-
&& go build main.go
17-
FROM alpine:3.7
18-
COPY --from=0 /casdoor /
19-
COPY --from=0 /usr/bin/wait-for-it /
20-
RUN set -eux \
21-
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
22-
&& apk update \
23-
&& apk upgrade \
24-
&& apk add bash
25-
CMD ./wait-for-it db:3306 && ./main
1+
FROM golang:1.16 AS BACK
2+
WORKDIR /go/src/casdoor
3+
COPY . .
4+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o server . \
5+
&& apt update && apt install wait-for-it && chmod +x /usr/bin/wait-for-it
6+
7+
FROM node:14.17.4 AS FRONT
8+
WORKDIR /web
9+
COPY ./web .
10+
RUN npm install && npm run build
11+
12+
FROM alpine:latest
13+
LABEL MAINTAINER="https://casdoor.org/"
14+
15+
COPY --from=BACK /go/src/casdoor/ ./
16+
COPY --from=BACK /usr/bin/wait-for-it ./
17+
RUN mkdir -p web/build && apk add --no-cache bash coreutils
18+
COPY --from=FRONT /web/build /web/build
19+
ENTRYPOINT ["./wait-for-it", "db:3306 ", "--", "./server"]

README.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
Casdoor
2-
====
3-
4-
[![Go Report Card](https://goreportcard.com/badge/github.com/casbin/casdoor)](https://goreportcard.com/report/github.com/casbin/casdoor) <img src="https://img.shields.io/github/license/casbin/casdoor?style=flat-square" alt="license"> [![GitHub issues](https://img.shields.io/github/issues/casbin/casdoor?style=flat-square)](https://github.com/casbin/casdoor/issues) [![GitHub stars](https://img.shields.io/github/stars/casbin/casdoor?style=flat-square)](https://github.com/casbin/casdoor/stargazers) [![GitHub forks](https://img.shields.io/github/forks/casbin/casdoor?style=flat-square)](https://github.com/casbin/casdoor/network)
5-
6-
Casdoor is a UI-first centralized authentication / Single-Sign-On (SSO) platform based on OAuth 2.0 / OIDC.
1+
<h1 align="center" style="border-bottom: none;">📦⚡️ Casdoor</h1>
2+
<h3 align="center">A UI-first centralized authentication / Single-Sign-On (SSO) platform based on OAuth 2.0 / OIDC.</h3>
3+
<p align="center">
4+
<a href="https://goreportcard.com/report/github.com/casbin/casdoor">
5+
<img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/casbin/casdoor">
6+
</a>
7+
<a href="https://github.com/casbin/casdoor/blob/master/LICENSE">
8+
<img src="https://img.shields.io/github/license/casbin/casdoor?style=flat-square" alt="license">
9+
</a>
10+
<a href="#badge">
11+
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
12+
</a>
13+
<a href="https://github.com/casbin/casdoor/issues">
14+
<img alt="GitHub issues" src="https://img.shields.io/github/issues/casbin/casdoor?style=flat-square">
15+
</a>
16+
<a href="#">
17+
<img alt="GitHub stars" src="https://img.shields.io/github/stars/casbin/casdoor?style=flat-square">
18+
</a>
19+
<a href="https://github.com/casbin/casdoor/network">
20+
<img alt="GitHub forks" src="https://img.shields.io/github/forks/casbin/casdoor?style=flat-square">
21+
</a>
22+
</p>
723

824
## Online demo
925

@@ -97,8 +113,6 @@ dataSourceName = root:123@tcp(db:3306)/
97113
98114
#### Run
99115

100-
Just execute:
101-
102116
```bash
103117
docker-compose up
104118
```

docker-compose.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ services:
33
casdoor:
44
build:
55
context: ./
6-
dockerfile: go-dockerfile
6+
dockerfile: Dockerfile
77
ports:
88
- "8000:8000"
99
depends_on:
1010
- db
11+
command: ["./wait-for-it db:3306 -- ./server"]
1112
volumes:
1213
- ./conf:/conf/
1314
db:

0 commit comments

Comments
 (0)