release #255
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
name: release | |
on: | |
workflow_run: | |
workflows: [ tests ] | |
types: [ completed ] | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
types: [opened, synchronize, reopened, labeled, unlabeled] | |
env: | |
APP_NAME: 'manticore-backup' | |
MAINTAINER: 'Manticore' | |
DESC: 'Manticore Backup' | |
jobs: | |
update-version: | |
if: > | |
github.event_name == 'push' && github.ref == 'refs/heads/main' || | |
github.event_name == 'pull_request' && contains( | |
github.event.pull_request.labels.*.name, 'pack' | |
) | |
runs-on: ubuntu-24.04 | |
outputs: | |
version: ${{ steps.semver-tagger.outputs.version }} | |
version_full: ${{ steps.semver-tagger.outputs.version_full }} | |
version_rpm: ${{ steps.semver-tagger.outputs.version_rpm }} | |
version_deb: ${{ steps.semver-tagger.outputs.version_deb }} | |
target: ${{ steps.semver-tagger.outputs.target }} | |
permissions: | |
contents: write | |
steps: | |
- id: semver-tagger | |
uses: manticoresoftware/semver-tagger-action@main | |
vars: | |
needs: update-version | |
if: needs.update-version.outputs.version != '' | |
runs-on: ubuntu-22.04 | |
outputs: | |
target: ${{ steps.vars.outputs.target }} | |
version_full: ${{ steps.vars.outputs.version_full }} | |
version_rpm: ${{ steps.vars.outputs.version_rpm }} | |
version_deb: ${{ steps.vars.outputs.version_deb }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref || github.ref }} | |
- id: vars | |
run: | | |
# Use version and target from update-version job | |
version_full="${{ needs.update-version.outputs.version_full }}" | |
version_rpm="${{ needs.update-version.outputs.version_rpm }}" | |
version_deb="${{ needs.update-version.outputs.version_deb }}" | |
target="${{ needs.update-version.outputs.target }}" | |
echo "version_full=$version_full" >> $GITHUB_OUTPUT | |
echo "version_rpm=$version_rpm" >> $GITHUB_OUTPUT | |
echo "version_deb=$version_deb" >> $GITHUB_OUTPUT | |
echo "target=$target" >> $GITHUB_OUTPUT | |
build-artifact: | |
runs-on: ubuntu-22.04 | |
needs: | |
- vars | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build binary | |
run: | | |
git clone https://github.com/manticoresoftware/phar_builder.git | |
./phar_builder/bin/build --name="Manticore Backup" --package="${{ env.APP_NAME }}" | |
- name: Create artifact | |
run: | | |
name="${{ env.APP_NAME }}_${{ needs.vars.outputs.version_full }}" | |
echo "$name" | |
echo "${{ needs.vars.outputs.version_full }}" > build/APP_VERSION | |
mkdir build/bin | |
cp build/${{ env.APP_NAME }} build/bin/${{ env.APP_NAME }} | |
tar czf "$name.tar.gz" -C build bin/${{ env.APP_NAME }} share | |
zip "$name.zip" build/${{ env.APP_NAME }}.ps1 | |
shell: bash | |
- uses: manticoresoftware/upload_artifact_with_retries@main | |
with: | |
name: artifact | |
path: ./*.{tar.gz,zip} | |
sign-windows-artifact: | |
needs: | |
- build-artifact | |
runs-on: windows-2019 | |
steps: | |
- name: Import code signing certificate | |
shell: powershell | |
run: | | |
$pfxCertFilePath = Join-Path -Path $PSScriptRoot -ChildPath "CodeSigningCertificate.pfx" | |
Set-Content -Value $([System.Convert]::FromBase64String($env:BASE64_PFX)) -Path $pfxCertFilePath -Encoding Byte | |
$codeSigningCert = Import-PfxCertificate -FilePath $pfxCertFilePath -Password $($env:PFX_PASSWORD | ConvertTo-SecureString -AsPlainText -Force) -CertStoreLocation Cert:\CurrentUser\My | |
env: | |
BASE64_PFX: ${{ secrets.CODESIGN_PFX_BASE64 }} | |
PFX_PASSWORD: ${{ secrets.CODESIGN_PFX_PASSWORD }} | |
- uses: manticoresoftware/download_artifact_with_retries@main | |
with: | |
name: artifact | |
path: . | |
- name: Sign PowerShell scripts | |
shell: powershell | |
run: | | |
Expand-Archive -Path "*.zip" -DestinationPath . | |
$scripts = Get-ChildItem -Path . -Filter ".\build\*.ps1" -ErrorAction Stop | |
# load cert | |
$codeSigningCert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1 | |
foreach ($script in $scripts) { | |
try { | |
$scriptContent = Get-Content -Path $script.FullName | |
Write-Output "Signing script `"$($script.Name)`" with certificate `"$($codeSigningCert.Thumbprint)`"" | |
# sign script | |
$null = Set-AuthenticodeSignature -Certificate $codeSigningCert -FilePath $script.FullName -TimestampServer "http://timestamp.comodoca.com/rfc3161" | |
} | |
catch { | |
Write-Error $_ | |
} | |
} | |
# Now recompress signed script | |
$zipFile = Get-ChildItem -Path . -Filter "*.zip" | Select-Object -First 1 | |
Remove-Item -Path $zipFile | |
[system.io.directory]::CreateDirectory(".\bin") | |
Move-Item ".\build\*.ps1" ".\bin\" | |
Compress-Archive -Path ".\bin" -DestinationPath $zipFile | |
- uses: manticoresoftware/upload_artifact_with_retries@main | |
with: | |
name: artifact | |
path: ./*.{tar.gz,zip} | |
build-linux-packages: | |
runs-on: ubuntu-22.04 | |
needs: | |
- vars | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build binary | |
run: | | |
git clone https://github.com/manticoresoftware/phar_builder.git | |
./phar_builder/bin/build --template=sh --name="Manticore Backup" --package="${{ env.APP_NAME }}" | |
- name: Prepare packages structure | |
run: | | |
mkdir -p .debpkg/usr/bin | |
mkdir -p .debpkg/usr/share/manticore/modules/${{ env.APP_NAME }} | |
mkdir -p .rpmpkg/usr/bin | |
mkdir -p .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }} | |
cp -rp build/share/modules/${{ env.APP_NAME }}/* .debpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/ | |
cp -rp build/share/modules/${{ env.APP_NAME }}/* .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/ | |
cp -r build/${{ env.APP_NAME }} .debpkg/usr/bin/${{ env.APP_NAME }} | |
cp -r build/${{ env.APP_NAME }} .rpmpkg/usr/bin/${{ env.APP_NAME }} | |
cp -p LICENSE .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/LICENSE | |
cp -p README.md .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/README.md | |
echo "${{ needs.vars.outputs.version_full }}" > .debpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/APP_VERSION | |
echo "${{ needs.vars.outputs.version_full }}" > .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/APP_VERSION | |
sudo chown -R root:root .debpkg | |
sudo chown -R root:root .rpmpkg | |
shell: bash | |
- uses: manticoresoftware/actions-build-deb-action@master | |
with: | |
package: ${{ env.APP_NAME }} | |
package_root: .debpkg | |
maintainer: ${{ env.MAINTAINER }} | |
version: ${{ needs.vars.outputs.version_deb }} | |
arch: 'all' | |
desc: '${{ env.DESC }}' | |
license: 'GPL-2.0-or-later' | |
- name: Build RPM packages | |
run: | | |
sudo apt-get update -y -q | |
sudo apt-get install -y rpm | |
RPMBUILD_DIR="$HOME/rpmbuild" | |
RPMBUILD_SOURCE_DIR="$RPMBUILD_DIR/SOURCES" | |
RPMBUILD_SPEC_DIR="$RPMBUILD_DIR/SPECS" | |
WORKDIR="/tmp/work" | |
mkdir "$WORKDIR" | |
spec_file=main.spec | |
cp "packages/$spec_file" "$WORKDIR" | |
cp -rp ".rpmpkg" "$WORKDIR/${{ env.APP_NAME }}" | |
cd "$WORKDIR" | |
# Prepare spec file for RPM | |
sed -i 's/{{ NAME }}/${{ env.APP_NAME }}/g' $spec_file | |
sed -i 's/{{ VERSION }}/${{ needs.vars.outputs.version_rpm }}/g' $spec_file | |
sed -i 's/{{ MAINTAINER }}/${{ env.MAINTAINER }}/g' $spec_file | |
sed -i 's/{{ DESC }}/${{ env.DESC }}/g' $spec_file | |
tar czf tmp.tar.gz "${{ env.APP_NAME }}/" | |
mkdir -p "$RPMBUILD_SOURCE_DIR" | |
mkdir -p "$RPMBUILD_SPEC_DIR" | |
mv tmp.tar.gz "$RPMBUILD_SOURCE_DIR" | |
cp -p $spec_file "$RPMBUILD_SPEC_DIR" | |
rpmbuild -bb "$RPMBUILD_SPEC_DIR/$spec_file" | |
ls -lah "$RPMBUILD_DIR/RPMS/noarch"/*.rpm | |
cp -p "$RPMBUILD_DIR/RPMS/noarch"/*.rpm $GITHUB_WORKSPACE | |
- name: Rename packages to proper name | |
run: | | |
ls -la ./*.rpm | |
version=${{ needs.vars.outputs.version_rpm }} | |
rpm_path="./${{ env.APP_NAME }}-${version}-1.noarch.rpm" | |
cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el7.noarch.rpm" | |
cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el8.noarch.rpm" | |
mv $rpm_path "./${{ env.APP_NAME }}-${version}-1.el9.noarch.rpm" | |
ls -la ./*.deb | |
- uses: manticoresoftware/upload_artifact_with_retries@main | |
with: | |
name: artifact-deb | |
path: ./*.deb | |
- uses: manticoresoftware/upload_artifact_with_retries@main | |
with: | |
name: artifact-el7-rpm | |
path: ./*.el7.noarch.rpm | |
- uses: manticoresoftware/upload_artifact_with_retries@main | |
with: | |
name: artifact-el8-rpm | |
path: ./*.el8.noarch.rpm | |
- uses: manticoresoftware/upload_artifact_with_retries@main | |
with: | |
name: artifact-el9-rpm | |
path: ./*.el9.noarch.rpm | |
create-release: | |
runs-on: ubuntu-22.04 | |
needs: | |
- build-artifact | |
- build-linux-packages | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate changelog | |
run: | | |
bin/git-changelog > ./changelog | |
- 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 }} | |
body_path: ./changelog | |
draft: true | |
prerelease: false | |
deploy: | |
needs: | |
- build-artifact | |
- sign-windows-artifact | |
- build-linux-packages | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
include: | |
- artifact: artifact-deb | |
type: deb | |
arch: all | |
delimiter: "-" | |
distro: buster | |
- artifact: artifact-deb | |
type: deb | |
arch: all | |
delimiter: "-" | |
distro: bionic | |
- artifact: artifact-deb | |
type: deb | |
arch: all | |
delimiter: "-" | |
distro: focal | |
- artifact: artifact-deb | |
type: deb | |
arch: all | |
delimiter: "-" | |
distro: jammy | |
- artifact: artifact-deb | |
type: deb | |
arch: all | |
delimiter: "-" | |
distro: bullseye | |
- artifact: artifact-deb | |
type: deb | |
arch: all | |
delimiter: "-" | |
distro: bookworm | |
- artifact: artifact-el7-rpm | |
type: rpm | |
arch: noarch | |
delimiter: "_" | |
distro: 7 | |
- artifact: artifact-el8-rpm | |
type: rpm | |
arch: noarch | |
delimiter: "_" | |
distro: 8 | |
- artifact: artifact-el9-rpm | |
type: rpm | |
arch: noarch | |
delimiter: "_" | |
distro: 9 | |
- artifact: artifact | |
type: arc | |
arch: noarch | |
delimiter: "-" | |
distro: "" | |
steps: | |
- name: Deploy package | |
uses: manticoresoftware/publish_to_repo@main | |
with: | |
ssh_key: ${{ secrets.REPO_SSH_KEY }} | |
distr: ${{ matrix.distro }} | |
arch: ${{ matrix.arch }} | |
artifact: ${{ matrix.artifact }} | |
type: ${{ matrix.type }} | |
delimiter: ${{ matrix.delimiter }} | |
target: ${{ env.target }} | |
update-manticoresearch-deps: | |
needs: | |
- vars | |
- deploy | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Update deps | |
uses: manticoresoftware/manticoresearch/actions/update-deps@master | |
with: | |
name: backup | |
version: "${{ needs.vars.outputs.version_full }}" | |
token: ${{ secrets.PR_TOKEN }} |