Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/release automation #4

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Build

on: [push, workflow_dispatch]
on:
pull_request:
push:
workflow_call:
outputs:
artifact_name:
description: Name of the sanoid-portable artifact uploaded during the build.
value: ${{ jobs.build.outputs.artifact_name }}
workflow_dispatch:

jobs:
build:
Expand All @@ -10,8 +18,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize build environment
run: ./init.sh

- name: Build sanoid-portable binary
run: |
# Build on Ubuntu
Expand All @@ -22,9 +32,11 @@ jobs:
sudo update-binfmts --install APE /bin/sh --magic MZqFpD

./build.sh

- name: Set artifact name
id: set_artifact_name
run: echo "artifact_name=sanoid-portable.${{ github.sha }}.${{ github.run_number }}" >> $GITHUB_OUTPUT

- name: Upload built sanoid-portable artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -39,10 +51,12 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download sanoid-portable artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact_name }}

- name: Test on Ubuntu
run: |
# Test on Ubuntu
Expand All @@ -53,6 +67,7 @@ jobs:
sudo update-binfmts --install APE /bin/sh --magic MZqFpD

./test.sh

- name: Test in FreeBSD
uses: vmactions/freebsd-vm@v1
with:
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release

on:
release:
types: [published]

jobs:
call-build-workflow:
uses: ./.github/workflows/build.yml

release:
runs-on: ubuntu-latest
needs: call-build-workflow
permissions:
contents: write
id-token: write
attestations: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download sanoid-portable artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.call-build-workflow.outputs.artifact_name }}

- name: Assert Changelog updated for release version
run: |
version='${{ github.event.release.tag_name }}'
version_heading="## $version"

if ! grep -q "$version_heading" CHANGELOG.md; then
echo "Error: CHANGELOG.md does not appear to contain release notes for \"$version\". A heading matching \"$version_heading\" was not found."
exit 1
fi

echo "Ok: CHANGELOG.md contains release notes for \"$version\"."

- name: Assert sanoid-portable version matches GitHub Release version
run: |
sudo update-binfmts --install APE /bin/sh --magic MZqFpD

sudo chmod +x sanoid-portable
sanoid_version=$(./sanoid-portable --version)
release_version="${{ github.event.release.tag_name }}"

echo "GitHub Release: $release_version"
echo "sanoid-portable: $sanoid_version"

if [ "$release_version" != "$sanoid_version" ]; then
echo "Error: GitHub Release version \"$release_version\" does not match sanoid-portable version \"$sanoid_version\"."
exit 1
fi

echo 'Ok: sanoid-portable version matches GitHub release version.'
sha256sum sanoid-portable

- uses: actions/attest-build-provenance@v2
with:
subject-path: sanoid-portable

- name: Upload sanoid-portable to GitHub Release assets
uses: softprops/action-gh-release@v2
with:
files: sanoid-portable
tag_name: ${{ github.event.release.tag_name }}
fail_on_unmatched_files: true
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@

## 2.2.0-1

Initial sanoid-portable release using Sanoid [v2.2.0](https://github.com/jimsalterjrs/sanoid/tree/v2.2.0).
Initial sanoid-portable release.

Uses Sanoid [v2.2.0](https://github.com/jimsalterjrs/sanoid/releases/tag/v2.2.0).
Loading