Skip to content

Various UX and perf improvements. Additional benchmarks (#7) #35

Various UX and perf improvements. Additional benchmarks (#7)

Various UX and perf improvements. Additional benchmarks (#7) #35

name: Build & Release
on:
push:
tags:
- '*.*.*'
workflow_dispatch:
jobs:
lint:
uses: ./.github/workflows/lint.yaml
coverage:
uses: ./.github/workflows/coverage.yaml
benchmark:
uses: ./.github/workflows/benchmark.yaml
build-and-test:
name: '${{ matrix.target }}'
needs:
- benchmark
- coverage
- lint
runs-on: ${{ matrix.runs-on }}
outputs:
CALCULATED_VERSION: ${{ steps.version.outputs.CALCULATED_VERSION }}
IS_PRE_RELEASE: ${{ steps.version.outputs.IS_PRE_RELEASE }}
PREV_RELEASE_VERSION: ${{ steps.version.outputs.PREV_RELEASE_VERSION }}
strategy:
matrix:
include:
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
- runs-on: macos-latest
target: x86_64-apple-darwin
- runs-on: windows-latest
target: x86_64-pc-windows-msvc
env:
RUST_LOG: trace
steps:
- uses: actions/checkout@v4
with:
# We set a the fetch depth so we expect BuildIt to be able to find the previous version tag.
# A value of 0 will fetch all commits, but that is overkill.
fetch-depth: 1000
# We also need to fetch tags as by default no tags are fetched if fetch-depth above is greater than 0.
# Tags are used to calculate the next version number.
- name: Fetch tags
run: git fetch --tags origin
- uses: ./.github/actions/detect-and-install-rust-toolchain
- uses: ./.github/actions/run-all-tests
- uses: ./.github/actions/install-buildit
- name: Set the build version
id: version
run: buildit version
- name: Build binaries for packaging
run: cargo build --release --all-features
- uses: ./.github/actions/package-linux
if: ${{ matrix.runs-on == 'ubuntu-latest' }}
with:
target: ${{ matrix.target }}
- uses: ./.github/actions/package-macos
if: ${{ matrix.runs-on == 'macos-latest' }}
with:
target: ${{ matrix.target }}
- uses: ./.github/actions/package-windows
if: ${{ matrix.runs-on == 'windows-latest' }}
with:
target: ${{ matrix.target }}
- name: Upload distribution artifacts
uses: actions/upload-artifact@v3
with:
name: dist-${{ matrix.target }}
path: ./artifacts/dist
- name: Upload Scoop artifacts
if: ${{ matrix.runs-on == 'windows-latest' && env.IS_PRE_RELEASE == 'false' }}
uses: actions/upload-artifact@v3
with:
name: scoop-manifest
path: ./artifacts/scoop
create-release:
name: Create release
needs: build-and-test
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
CALCULATED_VERSION: ${{ needs.build-and-test.outputs.CALCULATED_VERSION }}
IS_PRE_RELEASE: ${{ needs.build-and-test.outputs.IS_PRE_RELEASE }}
PREV_RELEASE_VERSION: ${{ needs.build-and-test.outputs.PREV_RELEASE_VERSION }}
permissions:
contents: write # Allow release creation
steps:
- uses: actions/checkout@v4
with:
# We set a the fetch depth so we expect minver_rs to be able to find the last version tag.
# A value of 0 will fetch all commits, but that is overkill.
fetch-depth: 1000
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Create release
shell: pwsh
run: |
$isPreReleaseVar = '${{ env.IS_PRE_RELEASE }}'
$prevReleaseVersion = '${{ env.PREV_RELEASE_VERSION }}'
$calculatedVersion = '${{ env.CALCULATED_VERSION }}'
Write-Host "IS_PRE_RELEASE = $isPreReleaseVar"
Write-Host "PREV_RELEASE_VERSION = $prevReleaseVersion"
Write-Host "CALCULATED_VERSION = $calculatedVersion"
$isPreRelease = $true
$preReleaseParam = '--prerelease'
if ($isPreReleaseVar -eq 'false') {
Write-Host 'This is a release'
$isPreRelease = $false
$preReleaseParam = $null
} else {
Write-Host 'This is a pre-release'
}
$hasPrevReleaseVersion = -not [string]::IsNullOrWhiteSpace($prevReleaseVersion)
if ($hasPrevReleaseVersion) {
Write-Host "Will create release $calculatedVersion from tag $prevReleaseVersion to tag $calculatedVersion"
gh release create $calculatedVersion $preReleaseParam --generate-notes --latest --notes-start-tag $prevReleaseVersion --title $calculatedVersion
} else {
Write-Host "Will create first release $calculatedVersion"
gh release create $calculatedVersion $preReleaseParam --notes 'First release' --title $calculatedVersion
}
$targets = @('x86_64-unknown-linux-musl', 'x86_64-apple-darwin', 'x86_64-pc-windows-msvc')
foreach ($target in $targets) {
$targetArtifactsDir = "./dist-$target"
if (Test-Path $targetArtifactsDir) {
gh release upload $calculatedVersion $targetArtifactsDir/*
}
}
publish-pages:
name: Publish Pages
needs: build-and-test
runs-on: ubuntu-latest
env:
IS_PRE_RELEASE: ${{ needs.build-and-test.outputs.IS_PRE_RELEASE }}
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: https://emilevr.github.io/space
steps:
- name: Download all workflow run artifacts
if: ${{ env.IS_PRE_RELEASE == 'false' }}
uses: actions/download-artifact@v3
- name: Package Pages artifacts
if: ${{ env.IS_PRE_RELEASE == 'false' }}
run: |
SITE_DIRECTORY=_site
SCOOP_MANIFEST_DIR="./scoop-manifest"
SITE_SCOOP_DIRECTORY="${SITE_DIRECTORY}/scoop"
COVERAGE_BADGE_DIR="./coverage-badge"
SITE_COVERAGE_DIRECTORY="${SITE_DIRECTORY}/coverage"
SITE_COVERAGE_BADGE_DIRECTORY="${SITE_COVERAGE_DIRECTORY}/badges"
mkdir -p $SITE_COVERAGE_DIRECTORY
mv $SCOOP_MANIFEST_DIR $SITE_SCOOP_DIRECTORY
mv $COVERAGE_BADGE_DIR $SITE_COVERAGE_BADGE_DIRECTORY
echo "Setting Pages file permissions"
chmod -c -R +rX "${SITE_DIRECTORY}/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Pages artifact
if: ${{ env.IS_PRE_RELEASE == 'false' }}
uses: actions/upload-pages-artifact@v2
- name: Deploy to GitHub Pages
if: ${{ env.IS_PRE_RELEASE == 'false' }}
id: deployment
uses: actions/deploy-pages@v2