|
| 1 | +name: Draft Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + paths: |
| 7 | + - VERSION |
| 8 | + branches: [main] |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + validate-release-commit: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout merge |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Get release commit info |
| 25 | + id: version |
| 26 | + run: | |
| 27 | + ver=$(cat VERSION) |
| 28 | + if ! echo "$ver" | grep -Eq '^[0-9]{4}\.[0-9]{2}\.[0-9]+$'; then |
| 29 | + echo "Invalid version format: $ver" |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | +
|
| 33 | + echo "version=$ver" >> $GITHUB_OUTPUT |
| 34 | +
|
| 35 | + headline="$(git show --format=%s ${{github.event.pull_request.head.sha}})" |
| 36 | + if ! echo "$headline" | grep -Eq "^[Rr]elease microcom $ver$"; then |
| 37 | + echo "Invalid commit headline: $headline" |
| 38 | + exit 1 |
| 39 | + fi |
| 40 | +
|
| 41 | + body="$( |
| 42 | + git show -s --format=%b ${{github.event.pull_request.head.sha}} \ |
| 43 | + | sed -E '/^Signed-off-by: /d' |
| 44 | + )" |
| 45 | +
|
| 46 | + echo 'body<<EOF' >> $GITHUB_OUTPUT |
| 47 | + echo "$body" >> $GITHUB_OUTPUT |
| 48 | + echo 'EOF' >> $GITHUB_OUTPUT |
| 49 | +
|
| 50 | + - name: Install Dependencies |
| 51 | + run: sudo apt install -y libreadline6-dev autoconf automake |
| 52 | + |
| 53 | + - name: Build release packages |
| 54 | + run: | |
| 55 | + autoreconf -i |
| 56 | + ./configure |
| 57 | + make dist |
| 58 | +
|
| 59 | + - name: Create or update release draft |
| 60 | + uses: softprops/action-gh-release@v2 |
| 61 | + with: |
| 62 | + draft: true |
| 63 | + tag_name: v${{steps.version.outputs.version}} |
| 64 | + name: microcom ${{steps.version.outputs.version}} |
| 65 | + body: ${{steps.version.outputs.body}} |
| 66 | + files: | |
| 67 | + microcom-*.tar.gz |
| 68 | + microcom-*.tar.xz |
| 69 | +
|
| 70 | + - run: gh pr edit "$NUMBER" --add-label "$LABELS" |
| 71 | + env: |
| 72 | + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 73 | + GH_REPO: ${{github.repository}} |
| 74 | + NUMBER: ${{github.event.pull_request.number}} |
| 75 | + LABELS: release |
0 commit comments