diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 1c6191d..b5455b3 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -11,8 +11,33 @@ jobs: name: Build and publish release runs-on: ubuntu-latest steps: + - name: Validate tag and determine prerelease flag + id: release_meta + shell: bash + run: | + set -eu + tag="${{ github.ref_name }}" + # Allowed tags: + # - Stable: 1.2.3 + # - Prerelease: 1.2.3-alpha1 | 1.2.3-beta1 | 1.2.3-rc1 + if [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "prerelease=false" >> "${GITHUB_OUTPUT}" + elif [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)[0-9]+$ ]]; then + echo "prerelease=true" >> "${GITHUB_OUTPUT}" + else + echo "Invalid tag format: ${tag}" + echo "Expected one of:" + echo " - 1.2.3" + echo " - 1.2.3-alpha1" + echo " - 1.2.3-beta1" + echo " - 1.2.3-rc1" + exit 1 + fi + - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5 @@ -62,7 +87,7 @@ jobs: for bin in dist/scratchbox-linux-*; do name="$(basename "${bin}")" - archive="scratchbox-${{ github.ref_name }}-${name}.tar.gz" + archive="scratchbox-${{ github.ref_name }}-${name#scratchbox-}.tar.gz" stage="release-packages/${name}" rm -rf "${stage}" @@ -72,10 +97,40 @@ jobs: tar -C "${stage}" -czf "${archive}" . done + - name: Generate release notes + shell: bash + run: | + set -eu + current_tag="${{ github.ref_name }}" + prev_tag="$(git tag --sort=-creatordate | awk -v cur="${current_tag}" '$0 != cur { print; exit }')" + + { + echo "## Release ${current_tag}" + echo + if [ -n "${prev_tag}" ]; then + echo "Changes since \`${prev_tag}\`:" + echo + git log --pretty='- %h %s' "${prev_tag}..${current_tag}" + else + echo "Changes in this release:" + echo + git log --pretty='- %h %s' "${current_tag}" + fi + echo + echo "## Artifacts" + echo + echo "- \`linux-amd64-default\`" + echo "- \`linux-amd64-static\`" + echo "- \`linux-arm64-default\`" + echo "- \`linux-arm64-static\`" + } > RELEASE_NOTES.md + - name: Create release and upload archives uses: https://gitea.com/actions/gitea-release-action@v1 with: tag_name: ${{ github.ref_name }} name: ${{ github.ref_name }} + prerelease: ${{ steps.release_meta.outputs.prerelease }} + body_path: RELEASE_NOTES.md files: |- scratchbox-${{ github.ref_name }}-linux-*.tar.gz diff --git a/README.md b/README.md index 368912b..36b8003 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,11 @@ Create config files with the image (writes to mounted `./docker-config`): Tagged releases provide `.tar.gz` archives with prebuilt Linux binaries. +Accepted release tag formats: + +- `1.2.3` (stable release) +- `1.2.3-alpha1`, `1.2.3-beta1`, `1.2.3-rc1` (prerelease) + Variant guide: | Variant | Recommended for | Notes |