Skip to content

chore: Update release workflow #20

chore: Update release workflow

chore: Update release workflow #20

Workflow file for this run

name: Release
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
# We need this to be able to create releases.
permissions:
contents: write
jobs:
# Create draft release with matching tag. Ensure matches cargo version.
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get the release version from the tag
if: env.VERSION == ''
run: echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')" >> $GITHUB_ENV
- name: Show the version
run: |
echo "version is: $VERSION"
- name: Check that tag version and Cargo.toml version are the same
shell: bash
run: |
if ! grep -q "version = \"$VERSION\"" Cargo.toml; then
echo "version does not match Cargo.toml" >&2
exit 1
fi
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create ${{ github.ref_name }} --draft --verify-tag --title ${{ github.ref_name }}
outputs:
version: ${{ env.VERSION }}
# Build and publish .deb file to release draft
build-and-publish-deb:
needs: ['create-release']
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Build .deb package
run: cargo deb
- name: Upload .deb to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
cd ./target/debian/
ls
deb_name=containeryard_${{ needs.create-release.outputs.version }}-1_amd64.deb
gh release upload "${{ github.ref_name }}" "$deb_name"