diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a198025..bf3e7ba 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,14 +2,20 @@ name: Build and publish release on: push: + branches: + - main tags: - '*' workflow_dispatch: inputs: release_tag: - description: 'Existing Git tag to publish' + description: 'GitHub Release tag to publish' required: true default: '0.7.3' + source_ref: + description: 'Source branch/tag/commit to compile' + required: true + default: 'main' permissions: contents: write @@ -24,20 +30,25 @@ jobs: runs-on: ubuntu-latest steps: - - name: Resolve release tag + - name: Resolve build metadata shell: bash run: | set -euo pipefail if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then echo "RELEASE_TAG=${{ inputs.release_tag }}" >> "$GITHUB_ENV" - else + echo "SOURCE_DESCRIPTION=${{ inputs.source_ref }}" >> "$GITHUB_ENV" + elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then echo "RELEASE_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" + echo "SOURCE_DESCRIPTION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" + else + echo "RELEASE_TAG=dev" >> "$GITHUB_ENV" + echo "SOURCE_DESCRIPTION=${GITHUB_SHA}" >> "$GITHUB_ENV" fi - - name: Checkout release tag + - name: Checkout source uses: actions/checkout@v4 with: - ref: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }} + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.source_ref || github.ref }} fetch-depth: 0 - name: Install Zig @@ -56,6 +67,7 @@ jobs: -Ddpslog=true - name: Collect release DLLs + if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') shell: bash run: | set -euo pipefail @@ -87,6 +99,7 @@ jobs: done - name: Add custom WeirdPerformance v0.7.3 + if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') shell: bash run: | set -euo pipefail @@ -120,6 +133,7 @@ jobs: PY - name: Create checksums and ZIP + if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') shell: bash run: | set -euo pipefail @@ -130,6 +144,7 @@ jobs: zip -j "WeirdUtils-${RELEASE_TAG}.zip" release/*.dll release/SHA256SUMS.txt - name: Publish GitHub Release + if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') shell: bash env: GH_TOKEN: ${{ github.token }} @@ -139,9 +154,9 @@ jobs: cat > release-notes.md <