-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (120 loc) · 4.19 KB
/
Copy pathrelease.yml
File metadata and controls
141 lines (120 loc) · 4.19 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
name: Release Package
on:
push:
tags:
- 'v*.*.*'
# Add permissions needed for creating releases
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
goarch: amd64
deb_arch: amd64
rpm_arch: x86_64
- arch: arm64
goarch: arm64
deb_arch: arm64
rpm_arch: aarch64
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
- name: Install FPM
run: gem install fpm
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Fix go.mod version
run: |
# Update go.mod with a valid Go version
sed -i 's/go 1.24.3/go 1.24/' go.mod
- name: Build binary for ${{ matrix.arch }}
run: GOARCH=${{ matrix.goarch }} go build -o agent
- name: Make scripts executable
run: chmod +x scripts/postinstall.sh
- name: Package DEB for ${{ matrix.arch }}
run: |
fpm -s dir -t deb -n agent -v ${{ env.VERSION }} \
--architecture ${{ matrix.deb_arch }} \
--description "Remote file opener via REST API" \
--maintainer "Sai Sanjay <saisanjay7660@gmail.com>" \
--depends "apt" \
--after-install scripts/postinstall.sh \
--deb-pre-depends "apt" \
./agent=/usr/local/bin/agent \
./agent.service=/lib/systemd/system/agent.service \
./dependencies.txt=/usr/share/agent/dependencies.txt
- name: Package RPM for ${{ matrix.arch }}
run: |
fpm -s dir -t rpm -n agent -v ${{ env.VERSION }} \
--architecture ${{ matrix.rpm_arch }} \
--description "Remote file opener via REST API" \
--maintainer "Sai Sanjay <saisanjay7660@gmail.com>" \
--depends "yum" \
--after-install scripts/postinstall.sh \
./agent=/usr/local/bin/agent \
./agent.service=/usr/lib/systemd/system/agent.service \
./dependencies.txt=/usr/share/agent/dependencies.txt
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.arch }}
path: |
agent_${{ env.VERSION }}_${{ matrix.deb_arch }}.deb
agent-${{ env.VERSION }}-1.${{ matrix.rpm_arch }}.rpm
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Get the version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: packages
- name: Display structure of downloaded files
run: ls -R packages
- name: Flatten directory structure
run: |
mkdir -p release_files
find packages -type f -name "*.deb" -o -name "*.rpm" | xargs -I {} cp {} release_files/
- name: Create "any" and "noarch" packages
run: |
# For demonstration, create copies of the amd64 packages for architecture-independent packages
cd release_files
ls -la
# Find the correct files dynamically instead of hardcoding names
AMDEB=$(find . -name "*amd64.deb" | head -1)
AMRPM=$(find . -name "*x86_64.rpm" | head -1)
if [ -n "$AMDEB" ]; then
cp "$AMDEB" "agent_${VERSION}_any.deb"
else
echo "Warning: No amd64 DEB package found"
fi
if [ -n "$AMRPM" ]; then
cp "$AMRPM" "agent-${VERSION}-1.noarch.rpm"
else
echo "Warning: No x86_64 RPM package found"
fi
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: release_files/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}