Skip to content

Commit

Permalink
Create and upload rpm package on release
Browse files Browse the repository at this point in the history
  • Loading branch information
Westwooo committed Nov 18, 2024
1 parent d7b2f37 commit 678b5b9
Showing 1 changed file with 127 additions and 59 deletions.
186 changes: 127 additions & 59 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ jobs:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
arch: amd64
rpmarch: x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
arch: arm64
rpmarch: aarch64
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
Expand All @@ -54,6 +56,10 @@ jobs:
run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu -y
if: matrix.target == 'aarch64-unknown-linux-gnu'

- name: Install rpmdevtools
run: sudo apt-get install rpm
if: matrix.os == 'ubuntu-22.04'

- uses: SebRollen/toml-action@v1.0.1
id: version
with:
Expand All @@ -69,22 +75,22 @@ jobs:
args: --verbose --release --target ${{ matrix.target }} --features static-link-openssl
if: matrix.os == 'ubuntu-22.04'

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --release --target ${{ matrix.target }}
if: matrix.os == 'macos-latest'

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --release
env:
VCPKGRS_DYNAMIC: 1
RUSTFLAGS: -Ctarget-feature=+crt-static
if: matrix.os == 'windows-latest'
# - name: Build
# uses: actions-rs/cargo@v1
# with:
# command: build
# args: --verbose --release --target ${{ matrix.target }}
# if: matrix.os == 'macos-latest'

# - name: Build
# uses: actions-rs/cargo@v1
# with:
# command: build
# args: --verbose --release
# env:
# VCPKGRS_DYNAMIC: 1
# RUSTFLAGS: -Ctarget-feature=+crt-static
# if: matrix.os == 'windows-latest'

# - name: Test
# uses: actions-rs/cargo@v1
Expand All @@ -98,58 +104,120 @@ jobs:
7z a -ttar -so -an ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }} | 7z a -si ${{ env.RELEASE_BIN }}-${{ matrix.target }}.tar.gz
if: matrix.os == 'ubuntu-22.04'

- name: Install p7zip
# 7Zip not available on MacOS, install p7zip via homebrew.
run: brew install p7zip
if: matrix.os == 'macos-latest'

- name: Create archive for MacOS
id: createarchivemacos
run: |
7z a -tzip ${{ env.RELEASE_BIN }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }}
if: matrix.os == 'macos-latest'

- name: Create archive for Windows
id: createarchivewindows
run: |
choco install 7zip
7z a -tzip ${{ env.RELEASE_BIN }}-${{ matrix.target }}.zip ./target/release/${{ env.RELEASE_BIN_WINDOWS }} ${{ env.RELEASE_ADDS }}
if: matrix.os == 'windows-latest'

- name: Create Debian amd package
id: createdebianpkg
# - name: Install p7zip
# # 7Zip not available on MacOS, install p7zip via homebrew.
# run: brew install p7zip
# if: matrix.os == 'macos-latest'

# - name: Create archive for MacOS
# id: createarchivemacos
# run: |
# 7z a -tzip ${{ env.RELEASE_BIN }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }}
# if: matrix.os == 'macos-latest'
#
# - name: Create archive for Windows
# id: createarchivewindows
# run: |
# choco install 7zip
# 7z a -tzip ${{ env.RELEASE_BIN }}-${{ matrix.target }}.zip ./target/release/${{ env.RELEASE_BIN_WINDOWS }} ${{ env.RELEASE_ADDS }}
# if: matrix.os == 'windows-latest'

# - name: Create Debian package
# id: createdebianpkg
# run: |
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
# mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/DEBIAN
# echo "Package: couchbase-shell
# Version: ${{ steps.version.outputs.value }}
# Maintainer: jack.westwood@couchbase.com
# Architecture: ${{ matrix.arch }}
# Homepage: www.couchbase.sh
# Description: The modern and fun shell for Couchbase Server and Cloud" > ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/DEBIAN/control
# cp {LICENSE,LICENSE_AGREEMENT,NOTICES,README.md} ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
# cp ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
# dpkg --build ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}
# dpkg-deb --info ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
# if: matrix.os == 'ubuntu-22.04'

- name: Create rpm packages
id: createrpmpkgs
run: |
mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}
mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr
mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
mkdir couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/DEBIAN
echo "Package: couchbase-shell
mkdir /home/runner/rpmbuild
mkdir /home/runner/rpmbuild/BUILD
mkdir /home/runner/rpmbuild/RPMS
mkdir /home/runner/rpmbuild/SOURCES
mkdir /home/runner/rpmbuild/SPECS
mkdir /home/runner/rpmbuild/SPRMS
mkdir couchbase-shell-${{ steps.version.outputs.value }}
mkdir couchbase-shell-${{ steps.version.outputs.value }}/usr
mkdir couchbase-shell-${{ steps.version.outputs.value }}/usr/bin
cp ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ./couchbase-shell-${{ steps.version.outputs.value }}/usr/bin/couchbase-shell
cp {LICENSE,LICENSE_AGREEMENT,NOTICES,README.md} ./couchbase-shell-${{ steps.version.outputs.value }}/usr/bin
ls ./couchbase-shell-${{ steps.version.outputs.value }}/usr/bin
tar --create --file couchbase-shell-${{ steps.version.outputs.value }}-${{ matrix.rpmarch }}.tar.gz couchbase-shell-${{ steps.version.outputs.value }}
mv couchbase-shell-${{ steps.version.outputs.value }}-${{ matrix.rpmarch }}.tar.gz /home/runner/rpmbuild/SOURCES
echo "%define debug_package %{nil}
%define __strip /bin/true
Name: couchbase-shell
Release: 1
Summary: The modern and fun shell for Couchbase Server and Cloud
Source0: %{name}-${{ steps.version.outputs.value }}-%{_arch}.tar.gz
License: Apache Software License 2.0
Version: ${{ steps.version.outputs.value }}
Maintainer: jack.westwood@couchbase.com
Architecture: ${{ matrix.arch }}
Homepage: www.couchbase.sh
Description: The modern and fun shell for Couchbase Server and Cloud" > ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/DEBIAN/control
cp {LICENSE,LICENSE_AGREEMENT,NOTICES,README.md} ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
cp ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}/usr/bin
dpkg --build ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}
dpkg-deb --info ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
Vendor: Couchbase
%description
The modern and fun shell for Couchbase Server and Cloud
%define debug_package %{nil}
%define __strip /bin/true
%prep
%setup -q
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p /home/runner/rpmbuild/BUILDROOT/%{name}-${{ steps.version.outputs.value }}-1.%{_arch}/%{_bindir}
cp ./%{_bindir}/* /home/runner/rpmbuild/BUILDROOT/%{name}-${{ steps.version.outputs.value }}-1.%{_arch}/%{_bindir}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%{_bindir}/%{name}
%doc %{_bindir}/README.md
%license %{_bindir}/LICENSE
%{_bindir}/NOTICES
%{_bindir}/LICENSE_AGREEMENT" > /home/runner/rpmbuild/SPECS/couchbase-shell.spec
rpmbuild -bb /home/runner/rpmbuild/SPECS/couchbase-shell.spec --target ${{ matrix.rpmarch }} --define "_bindir /usr/bin"
if: matrix.os == 'ubuntu-22.04'

- name: Upload Debian artifacts
# - name: Upload Debian artifacts
# uses: actions/upload-artifact@v4
# with:
# name: couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
# path: ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
# if-no-files-found: error
# compression-level: 0
# if: matrix.os == 'ubuntu-22.04'

- name: Upload rpm artifacts
uses: actions/upload-artifact@v4
with:
name: couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
path: ./couchbase-shell_${{ steps.version.outputs.value }}_${{ matrix.target }}.deb
name: couchbase-shell-${{ steps.version.outputs.value }}-1.${{ matrix.rpmarch }}.rpm
path: /home/runner/rpmbuild/RPMS/${{ matrix.rpmarch }}/couchbase-shell-${{ steps.version.outputs.value }}-1.${{ matrix.rpmarch }}.rpm
if-no-files-found: error
compression-level: 0
if: matrix.os == 'ubuntu-22.04'

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.RELEASE_BIN }}-${{ matrix.target }}
path: ${{ env.RELEASE_BIN }}-${{ matrix.target }}*
if-no-files-found: error
# - name: Upload artifacts
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.RELEASE_BIN }}-${{ matrix.target }}
# path: ${{ env.RELEASE_BIN }}-${{ matrix.target }}*
# if-no-files-found: error

release:
needs: [ build ]
Expand Down Expand Up @@ -180,4 +248,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
name: Release v${{ needs.build.outputs.version }}
fail_on_unmatched_files: true
body: ${{ steps.tag_version.changelog }}
body: ${{ steps.tag_version.changelog }}

0 comments on commit 678b5b9

Please sign in to comment.