From 4cdf4a36417659e67abc6650cd4ed8609713b881 Mon Sep 17 00:00:00 2001 From: Joseph Larionov Date: Sat, 7 Dec 2024 10:07:00 -0800 Subject: [PATCH] Add release workflow --- .github/workflows/build.yml | 10 ++++++- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc80bbf..a62491e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9321407 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release + +on: + release: + types: [published] + +jobs: + call-build-workflow: + uses: ./.github/workflows/build.yml + + release: + runs-on: ubuntu-latest + needs: call-build-workflow + steps: + - name: Download sanoid-portable artifact + uses: actions/download-artifact@v4 + with: + name: ${{ needs.call-build-workflow.outputs.artifact_name }} + + - name: Assert CHANGELOG updated for this 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 + + sha256sum sanoid-portable + echo 'Ok: sanoid-portable version matches GitHub release version.' + + # - 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