|
1 |
| -name: Prepare release |
| 1 | +# Create a draft release when triggered via Github's UI or Github CLI |
| 2 | +name: Prepare Release |
2 | 3 |
|
3 | 4 | on:
|
4 |
| - push: |
5 |
| - tags: |
6 |
| - - "v[0-9]*.[0-9]*" |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + version: |
| 8 | + description: 'Version to release (e.g. 0.11.0)' |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
7 | 14 |
|
8 | 15 | jobs:
|
9 |
| - update-release-notes: |
10 |
| - name: Update release |
| 16 | + release: |
| 17 | + name: Prepare Release |
11 | 18 | runs-on: ubuntu-latest
|
12 | 19 | steps:
|
| 20 | + - name: Check version |
| 21 | + run: | |
| 22 | + if ! [[ '${{ inputs.version }}' =~ ^[0-9]+[.][0-9]+([.][0-9]+)?$ ]]; then |
| 23 | + echo '${{ inputs.version }} does not match expected format `major.minor.patch?`' >&2 |
| 24 | + exit 1 |
| 25 | + fi |
13 | 26 | - name: Checkout
|
14 | 27 | uses: actions/checkout@v4
|
15 |
| - - name: Create archive |
16 |
| - id: archive |
| 28 | + with: |
| 29 | + ref: master # only create releases from main branch |
| 30 | + - name: Read section from CHANGELOG.md |
| 31 | + id: extract-changelog |
| 32 | + uses: sean0x42/markdown-extract@v2 |
| 33 | + with: |
| 34 | + file: CHANGELOG.md |
| 35 | + pattern: ${{ inputs.version }} |
| 36 | + - name: Prepare release notes and artifacts |
17 | 37 | run: |
|
18 |
| - TAG="${GITHUB_REF_NAME}" |
19 |
| - REPOSITORY_NAME="${GITHUB_REPOSITORY#*/}" |
20 |
| - PREFIX="${REPOSITORY_NAME}-${TAG:1}" |
21 |
| - ARCHIVE="${PREFIX}.tar.gz" |
22 |
| -
|
23 |
| - echo "tgz=${ARCHIVE}" >> $GITHUB_OUTPUT |
24 |
| -
|
25 |
| - git archive --format=tar.gz --prefix="${PREFIX}/" -o "$ARCHIVE" "${TAG}" |
26 |
| - - name: Prepare bzlmod / WORKSPACE snippets |
27 |
| - run: .github/workflows/prepare_snippets.sh ${{ steps.archive.outputs.tgz }} > release_notes.txt |
28 |
| - - name: Generate changelog |
| 38 | + .github/workflows/release_prep.sh v${{ inputs.version }} > release_notes.txt |
| 39 | + printf '${{ steps.extract-changelog.outputs.markdown }}' >> release_notes.txt |
| 40 | + - name: Create draft release |
| 41 | + env: |
| 42 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
29 | 43 | run: |
|
30 |
| - printf '\n-----\n\n' >> release_notes.txt |
31 |
| - awk -f .github/workflows/changelog.awk CHANGELOG.md >> release_notes.txt |
32 |
| - - name: Release |
33 |
| - uses: softprops/action-gh-release@v2 |
34 |
| - with: |
35 |
| - draft: true |
36 |
| - body_path: release_notes.txt |
37 |
| - fail_on_unmatched_files: true |
38 |
| - files: ${{ steps.archive.outputs.tgz }} |
| 44 | + gh release create \ |
| 45 | + --draft \ |
| 46 | + --notes-file release_notes.txt \ |
| 47 | + --title v${{ inputs.version }} \ |
| 48 | + v${{ inputs.version }} \ |
| 49 | + rules_nixpkgs-${{ inputs.version }}.tar.gz |
0 commit comments