-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (122 loc) · 4.84 KB
/
Copy pathrelease.yml
File metadata and controls
143 lines (122 loc) · 4.84 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
pull-requests: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Generate changelog for release
id: changelog
run: |
# Extract the current version section from CHANGELOG.md
VERSION="${{ steps.get_version.outputs.VERSION }}"
# Find the section for this version and extract it
CHANGELOG_SECTION=$(awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | sed '$d' | tail -n +2)
if [ -z "$CHANGELOG_SECTION" ]; then
echo "No changelog section found for version $VERSION"
CHANGELOG_SECTION="See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details."
fi
# Save to file for GitHub release
echo "$CHANGELOG_SECTION" > /tmp/release_notes.md
# Also output for debugging
echo "CHANGELOG_SECTION<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG_SECTION" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_version.outputs.TAG_NAME }}
name: Release ${{ steps.get_version.outputs.TAG_NAME }}
body_path: /tmp/release_notes.md
draft: false
prerelease: ${{ contains(steps.get_version.outputs.TAG_NAME, '-alpha') || contains(steps.get_version.outputs.TAG_NAME, '-beta') || contains(steps.get_version.outputs.TAG_NAME, '-rc') }}
token: ${{ secrets.GITHUB_TOKEN }}
docker:
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# Extract major and minor versions
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f1-2)
echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT
echo "MINOR=$MINOR" >> $GITHUB_OUTPUT
# Generate build timestamp
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_OUTPUT
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
org.opencontainers.image.title=Transcript Create
org.opencontainers.image.description=YouTube video transcription service
org.opencontainers.image.version=${{ steps.get_version.outputs.VERSION }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT=${{ github.sha }}
BUILD_DATE=${{ steps.get_version.outputs.BUILD_DATE }}
VERSION=${{ steps.get_version.outputs.VERSION }}
notify:
runs-on: ubuntu-latest
needs: [release, docker]
if: always()
steps:
- name: Release notification
run: |
echo "Release workflow completed for ${{ github.ref_name }}"
echo "GitHub Release: ${{ needs.release.result }}"
echo "Docker Build: ${{ needs.docker.result }}"