chore: Update release workflow #15
Workflow file for this run
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: | |
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 $VERSION --draft --verify-tag --title $VERSION | |
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 package as artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: containeryard-deb | |
path: ./target/debian/*.deb | |
- name: Upload .deb to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash | |
run: | | |
cd ./target/debian/ | |
version="${{ needs.create-release.outputs.version }}" | |
deb_name=containeryard-${{ needs.create-release.outputs.version }}-1_amd64.deb | |
gh release upload "$version" "$deb_name" |