-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (145 loc) · 5.44 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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Release
on:
push:
tags:
- "v*"
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Create Release Directory
run: mkdir -p release
- name: Build DEB Package
run: |
mkdir -p debbuild/DEBIAN
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG#v}
cp srcenv debbuild
cp srcenv.1 debbuild
(
echo 'Package: srcenv'
echo 'Version: '$VERSION'-1'
echo 'Section: utils'
echo 'Priority: optional'
echo 'Architecture: all'
echo 'Depends: jq'
echo 'Maintainer: Jean-Philippe Leconte <ins0mniaque@gmail.com>'
echo 'Description: A cross-shell tool for sourcing POSIX compliant .env scripts'
echo 'Homepage: https://github.com/ins0mniaque/srcenv'
) | tee debbuild/DEBIAN/control
(
echo 'Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/'
echo 'Upstream-Name: srcenv'
echo 'Upstream-Contact: https://github.com/ins0mniaque/srcenv/issues'
echo 'Source: https://github.com/ins0mniaque/srcenv'
echo
echo 'Files: *'
echo 'Copyright: 2024 Jean-Philippe Leconte'
echo 'License: MIT'
echo
echo 'License: MIT'
sed 's/^/ /' LICENSE
) | tee debbuild/DEBIAN/copyright
dpkg-deb --build debbuild "release/srcenv_${VERSION}-1_all.deb"
- name: Build RPM Package
run: |
mkdir -p rpmbuild/BUILD
mkdir -p rpmbuild/BUILDROOT
mkdir -p rpmbuild/RPMS
mkdir -p rpmbuild/SOURCES
mkdir -p rpmbuild/SPECS
mkdir -p rpmbuild/SRPMS
TAG=${GITHUB_REF#refs/tags/}
URL="https://github.com/ins0mniaque/srcenv/archive/refs/tags/$TAG.tar.gz"
VERSION=${TAG#v}
curl -Ls "$URL" -o "rpmbuild/SOURCES/srcenv-$VERSION.tar.gz"
(
echo 'Name: srcenv'
echo 'Version: '$VERSION
echo 'Release: 1%{?dist}'
echo 'Summary: A cross-shell tool for sourcing POSIX compliant .env scripts'
echo 'BuildArch: noarch'
echo 'Requires: jq'
echo
echo 'License: MIT'
echo 'Source0: %{name}-%{version}.tar.gz'
echo
echo '%description'
echo 'A cross-shell tool for sourcing POSIX compliant .env scripts'
echo
echo '%prep'
echo '%setup -q'
echo
echo '%install'
echo 'rm -rf $RPM_BUILD_ROOT'
echo 'mkdir -p $RPM_BUILD_ROOT%{_bindir}'
echo 'mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1'
echo 'cp %{name} $RPM_BUILD_ROOT%{_bindir}'
echo 'cp %{name}.1 $RPM_BUILD_ROOT%{_mandir}/man1'
echo
echo '%clean'
echo 'rm -rf $RPM_BUILD_ROOT'
echo
echo '%files'
echo '%{_bindir}/%{name}'
echo '%{_mandir}/man1/%{name}.1.gz'
) | tee rpmbuild/SPECS/srcenv.spec
rpmbuild --define "_topdir $PWD/rpmbuild" -ba rpmbuild/SPECS/srcenv.spec
cp "rpmbuild/RPMS/noarch/srcenv-$VERSION-1.noarch.rpm" release
- name: Generate Checksum File
run: |
cd release
sha256sum * | tee SHA256SUMS
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create --generate-notes "${GITHUB_REF#refs/tags/}" release/*
- name: Checkout Homebrew Formula
uses: actions/checkout@v4
with:
repository: ins0mniaque/homebrew-srcenv
token: ${{ secrets.HOMEBREW_TOKEN }}
path: homebrew-srcenv
persist-credentials: true
- name: Update Homebrew Formula
run: |
TAG=${GITHUB_REF#refs/tags/}
URL="https://github.com/ins0mniaque/srcenv/archive/refs/tags/$TAG.tar.gz"
SHA256=$(curl -Ls "$URL" | shasum -a 256 | cut -c1-64)
VERSION=${TAG#v}
cd homebrew-srcenv
(
echo 'class Srcenv < Formula'
echo ' desc "Cross-shell tool for sourcing POSIX compliant .env scripts"'
echo ' homepage "https://github.com/ins0mniaque/srcenv"'
echo ' url "'$URL'"'
echo ' version "'$VERSION'"'
echo ' sha256 "'$SHA256'"'
echo ' license "MIT"'
echo
echo ' depends_on "jq"'
echo
echo ' def install'
echo ' bin.install "srcenv"'
echo ' man1.install "srcenv.1"'
echo ' end'
echo
echo ' test do'
echo ' expected_version = "srcenv #{version}"'
echo ' actual_version = shell_output("#{bin}/srcenv --version").strip'
echo ' assert_match expected_version, actual_version'
echo ' end'
echo 'end'
) | tee Formula/srcenv.rb
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
git add Formula/srcenv.rb
git commit -m "Bump srcenv to $VERSION"
git push