Create Release #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: workflow_dispatch | |
name: Create Release | |
env: | |
# Could, potentially automatically parse | |
# the bin name, but let's do it automatically for now. | |
RELEASE_BIN: cbsh | |
RELEASE_BIN_WINDOWS: cbsh.exe | |
# Space separated paths to include in the archive. | |
# Start relative paths with a dot if you don't want | |
# paths to be preserved. Use "/" as a delimiter. | |
RELEASE_ADDS: README.md LICENSE LICENSE_AGREEMENT NOTICES | |
RELEASE_ADDS_WINDOWS: README.md,LICENSE,LICENSE_AGREEMENT,NOTICES | |
jobs: | |
build: | |
name: Build release | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
target: [ x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-msvc ] | |
include: | |
- 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 | |
os: macos-latest | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
outputs: | |
version: ${{ steps.version.outputs.value }} | |
steps: | |
- uses: ilammy/setup-nasm@v1 | |
- uses: actions/checkout@v3 | |
- name: Update Rust Toolchain Target | |
run: | | |
echo "targets = ['${{matrix.target}}']" >> rust-toolchain.toml | |
- name: Setup Rust toolchain and cache | |
uses: actions-rust-lang/setup-rust-toolchain@v1.4.3 | |
- name: Install aarch64-linux gcc | |
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: | |
file: 'Cargo.toml' | |
field: 'package.version' | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: 'aarch64-linux-gnu-gcc' | |
with: | |
command: build | |
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: Test | |
# uses: actions-rs/cargo@v1 | |
# with: | |
# command: test | |
# args: --verbose | |
- name: Create archive for Linux | |
id: createarchivelinux | |
run: | | |
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 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 rpmbuild | |
mkdir rpmbuild/BUILD | |
mkdir rpmbuild/RPMS | |
mkdir rpmbuild/SOURCES | |
mkdir rpmbuild/SPECS | |
mkdir rpmbuild/SPRMS | |
mkdir couchbase-shell-${{ steps.version.outputs.value }} | |
cp ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ./couchbase-shell-${{ steps.version.outputs.value }}/couchbase-shell | |
cp {LICENSE,LICENSE_AGREEMENT,NOTICES,README.md} ./couchbase-shell-${{ steps.version.outputs.value }} | |
ls ./couchbase-shell-${{ steps.version.outputs.value }} | |
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 rpmbuild/SOURCES | |
echo "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 }} | |
Vendor: Couchbase | |
%description | |
The modern and fun shell for Couchbase Server and Cloud | |
%prep | |
%setup -q | |
%install | |
rm -rf $RPM_BUILD_ROOT | |
mkdir -p $RPM_BUILD_ROOT/%{_bindir} | |
cp %{name} $RPM_BUILD_ROOT/%{_bindir} | |
cp LICENSE LICENSE_AGREEMENT NOTICES README.md $RPM_BUILD_ROOT/%{_bindir} | |
%clean | |
rm -rf $RPM_BUILD_ROOT | |
%files | |
%{_bindir}/%{name} | |
%doc %{_bindir}/README.md | |
%license %{_bindir}/LICENSE | |
%{_bindir}/NOTICES | |
%{_bindir}/LICENSE_AGREEMENT" > rpmbuild/SPECS/couchbase-shell.spec | |
sudo rpmbuild -bb rpmbuild/SPECS/couchbase-shell.spec --target ${{ matrix.rpmarch }} --define "_bindir /usr/bin" | |
if: matrix.os == 'ubuntu-22.04' | |
# - 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 }}-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 | |
release: | |
needs: [ build ] | |
name: Create release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create tag | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ needs.build.outputs.version }} | |
default_bump: false | |
create_annotated_tag: true | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4.1.7 | |
- name: Add Artifacts to Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.RELEASE_BIN }}*/* | |
*/*.deb | |
tag_name: v${{ needs.build.outputs.version }} | |
draft: true | |
prerelease: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Release v${{ needs.build.outputs.version }} | |
fail_on_unmatched_files: true | |
body: ${{ steps.tag_version.changelog }} |