ci: add GitHub Actions for tests and releases, update README #1
Workflow file for this run
This file contains hidden or 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: | |
| tags: | |
| - "v*.*.*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.14.0 | |
| - name: Run tests | |
| run: zig build test | |
| release: | |
| name: Create Release | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| prev_tag=$(git tag --sort=-v:refname | head -2 | tail -1) | |
| if [ "$prev_tag" = "$GITHUB_REF_NAME" ] || [ -z "$prev_tag" ]; then | |
| echo "body<<ENDOFLOG" >> "$GITHUB_OUTPUT" | |
| echo "Initial release." >> "$GITHUB_OUTPUT" | |
| echo "ENDOFLOG" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "body<<ENDOFLOG" >> "$GITHUB_OUTPUT" | |
| echo "## What's Changed" >> "$GITHUB_OUTPUT" | |
| echo "" >> "$GITHUB_OUTPUT" | |
| git log "${prev_tag}..HEAD" --pretty=format:"- %s (%h)" --no-merges >> "$GITHUB_OUTPUT" | |
| echo "" >> "$GITHUB_OUTPUT" | |
| echo "" >> "$GITHUB_OUTPUT" | |
| echo "**Full diff**: https://github.com/${{ github.repository }}/compare/${prev_tag}...${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| echo "ENDOFLOG" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ github.ref_name }} | |
| body: ${{ steps.changelog.outputs.body }} | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, '-') }} |