Skip to content

Commit 44f3f81

Browse files
authored
ci: add workflows and dependabot (#7)
* ci: add dependabot * ci: add workflow file for release * fix: pre-commit hooks * ci: remove docs style
1 parent 2bebf49 commit 44f3f81

File tree

3 files changed

+154
-7
lines changed

3 files changed

+154
-7
lines changed

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip" # See documentation for possible values
4+
directory: "/" # Location of package manifests
5+
schedule:
6+
interval: "weekly"
7+
groups:
8+
dev-dependencies:
9+
patterns:
10+
- "*"
11+
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "weekly"
16+
groups:
17+
action-deps:
18+
patterns:
19+
- "*"

.github/workflows/ci_cd.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: CI/CD
2+
on:
3+
pull_request:
4+
push:
5+
tags:
6+
- "*"
7+
branches:
8+
- main
9+
10+
env:
11+
MAIN_PYTHON_VERSION: '3.12'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: write
19+
packages: write
20+
21+
jobs:
22+
code-style:
23+
name: "Code style checks"
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: "Run PyAnsys code style checks"
27+
uses: ansys/actions/code-style@v6
28+
29+
release:
30+
name: "Release project"
31+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
32+
needs: [code-style]
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Release to GitHub
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
generate_release_notes: true
42+
43+
release-docker:
44+
name : Generate Docker release
45+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
46+
needs: [release]
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
55+
- name: Login to GitHub Container Registry
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ghcr.io
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Check if tag name contains 'dev'
63+
run: echo "IS_DEV_TAG=$(echo ${{ github.ref_name }} | grep -q 'dev' && echo 'true' || echo 'false')" >> $GITHUB_ENV
64+
65+
- name: Decompose tag into components
66+
if: env.IS_DEV_TAG == 'false'
67+
run: |
68+
if [[ ${{ github.ref_name }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
69+
# Split the tag into its components
70+
IFS='.' read -ra PARTS <<< "${{ github.ref_name }}"
71+
echo "X=${PARTS[0]}" >> $GITHUB_ENV
72+
echo "Y=${PARTS[1]}" >> $GITHUB_ENV
73+
echo "Z=${PARTS[2]}" >> $GITHUB_ENV
74+
else
75+
echo "Invalid tag format. Expected vX.Y.Z but got ${{ github.ref_name }}"
76+
exit 1
77+
fi
78+
79+
- name: Build and push Docker image
80+
uses: docker/build-push-action@v6
81+
if: env.IS_DEV_TAG == 'false'
82+
with:
83+
context: .
84+
file: docker/Dockerfile
85+
push: true
86+
platforms: linux/amd64,linux/arm64
87+
tags: |
88+
ghcr.io/${{ github.repository }}:${{ env.X }} ,
89+
ghcr.io/${{ github.repository }}:${{ env.X }}.${{ env.Y }} ,
90+
ghcr.io/${{ github.repository }}:${{ env.X }}.${{ env.Y }}.${{ env.Z }} ,
91+
ghcr.io/${{ github.repository }}:latest
92+
93+
- name: Build and push Docker image dev
94+
if: env.IS_DEV_TAG == 'true'
95+
uses: docker/build-push-action@v6
96+
with:
97+
context: .
98+
file: docker/Dockerfile
99+
push: true
100+
platforms: linux/amd64,linux/arm64
101+
tags: |
102+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
103+
104+
main-repo-release:
105+
name: Update main allie repo and create release
106+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
107+
needs: [release-docker, release]
108+
runs-on: ubuntu-latest
109+
steps:
110+
- name: Checkout allie repository
111+
run: |
112+
git clone --branch main https://${{ secrets.ALLIE_RELEASE_TOKEN }}@github.com/ansys-internal/allie.git
113+
114+
- name: Setup Go
115+
uses: actions/setup-go@v5
116+
with:
117+
go-version-file: 'allie/scripts/releasehelper/go.mod'
118+
119+
- name: Run tag script
120+
run: |
121+
cd allie/scripts/releasehelper
122+
go run main.go "tag" ${{ github.ref_name }} ${{ secrets.ALLIE_RELEASE_TOKEN }}
123+
124+
- name: Commit and push to allie
125+
run: |
126+
cd allie
127+
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
128+
git config --global user.name '${{ github.actor }}'
129+
git commit -a -m 'New release triggered by ${{ github.event.repository.name }}'
130+
git push origin main
131+
132+
- name: Run release script
133+
run: |
134+
cd allie/scripts/releasehelper
135+
go run main.go "release" ${{ github.ref_name }} ${{ secrets.ALLIE_RELEASE_TOKEN }}

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
repos:
2-
- repo: https://github.com/adamchainz/blacken-docs
3-
rev: 1.16.0
4-
hooks:
5-
- id: blacken-docs
6-
additional_dependencies:
7-
- black==23.12.1
8-
92
- repo: https://github.com/psf/black
103
rev: 23.12.1
114
hooks:

0 commit comments

Comments
 (0)