ci: fix typo in release job #33
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 Pipeline | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-pipeline: | |
name: "Build ${{ matrix.target }}" | |
strategy: | |
matrix: | |
target: | |
- aarch64-unknown-linux-gnu | |
- aarch64-apple-darwin | |
- x86_64-apple-darwin | |
- x86_64-pc-windows-msvc | |
- x86_64-unknown-linux-gnu | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-22.04 | |
- target: aarch64-unknown-linux-gnu | |
os: ubuntu-22.04 | |
cross: true | |
- target: aarch64-apple-darwin | |
os: macos-13 | |
- target: x86_64-apple-darwin | |
os: macos-13 | |
- target: x86_64-pc-windows-msvc | |
os: windows-2022 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
default: true | |
profile: minimal | |
target: ${{ matrix.target }} | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --locked --target=${{ matrix.target }} | |
use-cross: ${{ matrix.cross }} | |
- name: Create Unix Archive | |
if: ${{ !contains(matrix.target, 'windows') }} | |
env: | |
TARGET: ${{ matrix.target }} | |
srcdir: . | |
pkgdir: /tmp/pkg | |
run: | | |
mkdir -p ${pkgdir} | |
source scripts/ci/install | |
tar -czf tpi-${{ matrix.target }}.tar.gz -C ${pkgdir} . | |
- name: Upload Archive | |
uses: actions/upload-artifact@v4 | |
if: ${{ !contains(matrix.target, 'windows') }} | |
with: | |
name: ${{ matrix.target }} | |
path: | | |
tpi-${{ matrix.target }}.tar.gz | |
- name: Upload Archive (Win) | |
uses: actions/upload-artifact@v4 | |
if: ${{ contains(matrix.target, 'windows') }} | |
with: | |
name: ${{ matrix.target }} | |
path: | | |
target/${{ matrix.target }}/release/tpi.exe | |
debian-packages: | |
runs-on: ubuntu-latest | |
needs: build-pipeline | |
strategy: | |
matrix: | |
target: | |
- aarch64 | |
- x86_64 | |
include: | |
- target: x86_64 | |
arch: amd64 | |
- target: aarch64 | |
arch: arm64 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.target }}-unknown-linux-gnu | |
- name: Extract version from Cargo.toml | |
run: | | |
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
echo "PKG_NAME=tpi-$VERSION-${{ matrix.target }}-linux" >> $GITHUB_ENV | |
- name: Extract tar.gz file | |
run: | | |
mkdir ${{ env.PKG_NAME }} | |
tar -xf tpi-${{ matrix.target }}-unknown-linux-gnu.tar.gz -C ${{ env.PKG_NAME }} | |
- name: Create DEBIAN package | |
run: scripts/ci/create_debian_control.sh Cargo.toml ${{ matrix.arch }} ${{ env.PKG_NAME }} | |
- run: dpkg-deb --build ${{ env.PKG_NAME }} | |
- name: Upload Archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PKG_NAME }}.deb | |
path: ${{ env.PKG_NAME }}.deb | |
create-release: | |
runs-on: ubuntu-latest | |
needs: debian-packages | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract version from Cargo.toml | |
id: extract_version | |
run: | | |
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Check if tag exists | |
run: | | |
if git rev-parse --verify v${VERSION} >/dev/null 2>&1; then | |
echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
echo "no new version detected, aborting release Pipeline" | |
else | |
echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
fi | |
- name: Create new tag | |
if: ${{ env.TAG_EXISTS == 'false' }} | |
run: | | |
git config --global user.name "${{ github.actor }}" | |
git config --global user.email "[email protected]" | |
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}" | |
git push origin "v${{ env.VERSION }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Download artifacts | |
if: ${{ env.TAG_EXISTS == 'false' }} | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
merge-multiple: true | |
- name: Release | |
if: ${{ env.TAG_EXISTS == 'false' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
name: tpi v${{ env.VERSION }} | |
tag: v${{ env.VERSION }} | |
artifacts: artifacts/* | |
generateReleaseNotes: true |