Skip to content

Commit c0acf02

Browse files
committed
Added basic functionality: Global and Contests statistics monitoring and /track command to start tracking user on CodeForces
1 parent a4dea09 commit c0acf02

31 files changed

+1568
-21
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Create Release Branch Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
create_branch:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Extract version from file
17+
id: get-version
18+
run: |
19+
VERSION=$(./gradlew -q printProjectVersion)
20+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
21+
22+
- name: Create release branch
23+
run: |
24+
git config user.name "$GITHUB_ACTOR"
25+
git config user.email "[email protected]"
26+
git checkout -b release/${{ env.VERSION }}
27+
git push origin release/${{ env.VERSION }}
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main-branch.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Main Branch Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-jars:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '21'
20+
distribution: 'corretto'
21+
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v4
24+
25+
- name: Build with Gradle Wrapper
26+
run: ./gradlew build
27+
28+
- name: Extract project name from Gradle
29+
run: |
30+
PROJECT_NAME=$(./gradlew -q printProjectName)
31+
echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV
32+
33+
- name: Extract version from Gradle
34+
run: |
35+
VERSION=$(./gradlew -q printProjectVersion)
36+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
37+
38+
- name: Upload jars
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-jars
42+
path: build/libs/*.jar
43+
44+
build-and-push-docker:
45+
runs-on: ubuntu-latest
46+
permissions:
47+
packages: write
48+
id-token: write
49+
attestations: write
50+
env:
51+
REGISTRY: ghcr.io
52+
IMAGE_NAME: ${{ github.repository }}
53+
54+
steps:
55+
- name: Checkout repository
56+
uses: actions/checkout@v4
57+
58+
- name: Log in to GitHub Container Registry
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ${{ env.REGISTRY }}
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Extract version from file
66+
run: |
67+
VERSION=$(./gradlew -q printProjectVersion)
68+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
69+
70+
- name: Extract metadata (tags, labels) for Docker
71+
id: meta
72+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
73+
with:
74+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75+
76+
- name: Change wrapper permissions
77+
run: chmod +x ./gradlew
78+
79+
- name: Build and push Docker image
80+
id: push
81+
uses: docker/build-push-action@v6
82+
with:
83+
context: .
84+
push: true
85+
tags: ${{ steps.meta.outputs.tags }}
86+
labels: ${{ steps.meta.outputs.labels }}
87+
88+
- name: Generate artifact attestation
89+
uses: actions/attest-build-provenance@v1
90+
with:
91+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
92+
subject-digest: ${{ steps.push.outputs.digest }}
93+
push-to-registry: true
94+
build-git-badges:
95+
runs-on: ubuntu-latest
96+
97+
steps:
98+
- name: Checkout repository
99+
uses: actions/checkout@v4
100+
101+
- name: Calculate Lines of Code
102+
id: loc
103+
uses: PavanMudigonda/[email protected]
104+
with:
105+
include_ext: "kt,java"
106+
107+
- name: Add Lines of Code Summary
108+
run: echo "${{ steps.loc.outputs.lines-of-code-summary }}" >> $GITHUB_STEP_SUMMARY
109+
110+
- name: Output git info
111+
id: git_info
112+
run: |
113+
function format_size { echo $(numfmt --to iec --suffix B $1); }
114+
function format_number { LC_ALL=en_US.UTF-8 printf "%'d\n" $1; }
115+
echo "file_count=$(format_number $(git ls-files | wc -l))" >> $GITHUB_OUTPUT
116+
echo "lines_of_code=${{ steps.loc.outputs.total_lines_int }}" >> $GITHUB_OUTPUT
117+
git gc
118+
echo "size=$(format_size $(($(git count-objects -v | grep 'size-pack: ' | sed 's/size-pack: //g' | tr -d '\n') * 1024)))" >> $GITHUB_OUTPUT
119+
shell: bash
120+
121+
- name: Build-A-Badge
122+
uses: peterrhodesdev/[email protected]
123+
with:
124+
token: ${{ secrets.GITHUB_TOKEN }}
125+
filename: |
126+
(
127+
"[internal]-git-size"
128+
"[internal]-git-file-count"
129+
"[internal]-git-lines-of-code"
130+
)
131+
label: ("size" "files" "lines-of-code")
132+
message: |
133+
(
134+
"${{ steps.git_info.outputs.size }}"
135+
"${{ steps.git_info.outputs.file_count }}"
136+
"${{ steps.git_info.outputs.lines_of_code }}"
137+
)
138+
namedLogo: ("git" "git" "git")
139+
color: ("f1502f" "f1502f" "f1502f")
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
name: Release Branch Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- release/*
7+
workflow_run:
8+
workflows:
9+
- Create Release Branch Workflow
10+
types:
11+
- completed
12+
13+
jobs:
14+
build-jars:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK 21
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '21'
25+
distribution: 'corretto'
26+
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
30+
- name: Build with Gradle Wrapper
31+
run: ./gradlew build
32+
33+
- name: Extract project name from Gradle
34+
id: extract_name
35+
run: |
36+
PROJECT_NAME=$(./gradlew -q printProjectName)
37+
echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV
38+
39+
- name: Extract version from Gradle
40+
id: get-version
41+
run: |
42+
VERSION=$(./gradlew -q printProjectVersion)
43+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
44+
45+
- name: Upload jars
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-jars
49+
path: build/libs/*.jar
50+
51+
build-and-push-docker:
52+
runs-on: ubuntu-latest
53+
permissions:
54+
packages: write
55+
id-token: write
56+
attestations: write
57+
env:
58+
REGISTRY: ghcr.io
59+
IMAGE_NAME: ${{ github.repository }}
60+
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v4
64+
65+
- name: Log in to GitHub Container Registry
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ${{ env.REGISTRY }}
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Extract version from file
73+
run: |
74+
VERSION=$(./gradlew -q printProjectVersion)
75+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
76+
77+
- name: Extract metadata (tags, labels) for Docker
78+
id: meta
79+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
80+
with:
81+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
82+
83+
- name: Change wrapper permissions
84+
run: chmod +x ./gradlew
85+
86+
- name: Build and push Docker image
87+
id: push
88+
uses: docker/build-push-action@v6
89+
with:
90+
context: .
91+
push: true
92+
tags: ${{ steps.meta.outputs.tags }}, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
93+
labels: ${{ steps.meta.outputs.labels }}
94+
95+
- name: Generate artifact attestation
96+
uses: actions/attest-build-provenance@v1
97+
with:
98+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
99+
subject-digest: ${{ steps.push.outputs.digest }}
100+
push-to-registry: true
101+
102+
package-and-push-helm:
103+
runs-on: ubuntu-latest
104+
permissions:
105+
contents: write
106+
107+
steps:
108+
- name: Checkout repository
109+
uses: actions/checkout@v4
110+
with:
111+
fetch-depth: 0
112+
113+
- name: Configure Git
114+
run: |
115+
git config user.name "$GITHUB_ACTOR"
116+
git config user.email "[email protected]"
117+
118+
- name: Install Helm
119+
uses: azure/setup-helm@v4
120+
env:
121+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
122+
123+
- name: Run chart-releaser
124+
uses: helm/[email protected]
125+
with:
126+
packages_with_index: true
127+
env:
128+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
129+
130+
- name: Package Helm Chart
131+
run: |
132+
helm package ./charts/default --destination ./chart
133+
134+
- name: Extract project name from Gradle
135+
id: extract_name
136+
run: |
137+
PROJECT_NAME=$(./gradlew -q printProjectName)
138+
echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV
139+
140+
- name: Extract version from Gradle
141+
id: get-version
142+
run: |
143+
VERSION=$(./gradlew -q printProjectVersion)
144+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
145+
146+
- name: Upload Helm Chart
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-helm-chart
150+
path: chart/*.tgz
151+
152+
create-release:
153+
runs-on: ubuntu-latest
154+
needs:
155+
- build-jars
156+
- package-and-push-helm
157+
158+
steps:
159+
- name: Checkout repository
160+
uses: actions/checkout@v4
161+
162+
- name: Extract project name from Gradle
163+
id: extract_name
164+
run: |
165+
PROJECT_NAME=$(./gradlew -q printProjectName)
166+
echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV
167+
168+
- name: Extract version from Gradle
169+
id: get-version
170+
run: |
171+
VERSION=$(./gradlew -q printProjectVersion)
172+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
173+
174+
- name: Download jars
175+
uses: actions/download-artifact@v4
176+
with:
177+
name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-jars
178+
path: artifacts/
179+
180+
- name: Download Helm Chart
181+
uses: actions/download-artifact@v4
182+
with:
183+
name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-helm-chart
184+
path: artifacts/
185+
186+
- name: Release
187+
uses: softprops/action-gh-release@v2
188+
if: true
189+
with:
190+
tag_name: ${{ env.VERSION }}
191+
body_path: ./CHANGELOG.md
192+
files: |
193+
artifacts/*
194+
195+
dependency-submission:
196+
runs-on: ubuntu-latest
197+
permissions:
198+
contents: write
199+
200+
steps:
201+
- name: Checkout repository
202+
uses: actions/checkout@v4
203+
204+
- name: Set up JDK 21
205+
uses: actions/setup-java@v4
206+
with:
207+
java-version: '21'
208+
distribution: 'corretto'
209+
210+
- name: Generate and submit dependency graph
211+
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

0 commit comments

Comments
 (0)