-
Notifications
You must be signed in to change notification settings - Fork 3
91 lines (75 loc) · 2.54 KB
/
release.yml
File metadata and controls
91 lines (75 loc) · 2.54 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
name: Build, Package and Release
on:
push:
tags:
- 'v*'
jobs:
build_and_docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '22.x'
- name: Install Dependencies
run: npm install
- name: Run Build Script
run: npm run build
- name: Determine If Latest Tag Should Be Pushed
id: determine_latest_push
run: |
# Check if the tag matches the pattern "vX.Y.Z" (where X, Y, Z are integers)
if [[ "${{ github.ref_name }}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
LATEST_PUSH=true
else
LATEST_PUSH=false
fi
echo "LATEST_PUSH=${LATEST_PUSH}" >> $GITHUB_ENV
shell: bash
- name: Build and push Docker image
run: |
docker login -u reflectornet --password-stdin <<< ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
docker build -f ./docker/Dockerfile -t reflector-node .
docker tag reflector-node reflectornet/reflector-node:${{ github.ref_name }}
docker push reflectornet/reflector-node:${{ github.ref_name }}
if [ "${{ env.LATEST_PUSH }}" = "true" ]; then
# Push latest only if LATEST_PUSH is true
docker tag reflector-node reflectornet/reflector-node:latest
docker push reflectornet/reflector-node:latest
fi
- name: Archive dist directory into tar.gz
run: |
tar -czvf dist.tar.gz -C dist .
- name: Archive dist directory into zip
run: |
zip -r dist.zip dist/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload dist.tar.gz to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.tar.gz
asset_name: dist.tar.gz
asset_content_type: application/gzip
- name: Upload dist.zip to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.zip
asset_name: dist.zip
asset_content_type: application/zip