-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (74 loc) · 2.38 KB
/
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
name: Release Workflow
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
environment: Release Authentication
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
# Read the current version
- name: Read Current Version
id: version
run: |
VERSION=$(cat VERSION)
echo "Current Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
# Increment the patch version
- name: Increment Patch Version
id: increment
run: |
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "New Version: $NEW_VERSION"
echo "$NEW_VERSION" > VERSION
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
# Debug the Personal Access Token temporarily
- name: Debug PAT
run: |
echo "PAT length: ${#PAT}"
env:
PAT: ${{ secrets.PAT }}
# TEST COMMIT FOR PAT TOKEN LOCALLY
# Commit the new version
- name: Commit Updated Version
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add VERSION
git commit -m "Bump version to ${{ env.new_version }}"
git push https://${{ secrets.PAT }}@github.com/chrismuntean/Handify.git HEAD:main
# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Build and push Docker image
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
chrismuntean/Handify:latest
chrismuntean/Handify:${{ env.new_version }}
# Create GitHub Release
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ env.new_version }}
release_name: "Release ${{ env.new_version }}"
body: "Automated release."
draft: false
prerelease: false