File: publish-github.yml

package info (click to toggle)
python-certbot-dns-hetzner-cloud 1.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 168 kB
  • sloc: python: 317; makefile: 8
file content (78 lines) | stat: -rw-r--r-- 2,632 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: "Publish to GitHub"

on:
  workflow_run:
    workflows: [ "Build Release" ]
    types: [ completed ]

permissions:
  contents: write
  actions: read

jobs:
  github-release:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - name: "Download release artifacts"
        uses: actions/download-artifact@v4
        with:
          name: release-dists
          path: dist/
          repository: ${{ github.repository }}
          run-id: ${{ github.event.workflow_run.id }}
          github-token: ${{ github.token }}

      - name: "Extract Version from Tag"
        id: extract_tag
        uses: actions/github-script@v7
        with:
          script: |
            const {owner, repo} = context.repo;

            // 1) Run-Details des auslösenden Workflow-Runs holen
            const runId = context.payload.workflow_run?.id ?? ${{ github.event.workflow_run.id }};
            const { data: run } = await github.rest.actions.getWorkflowRun({
              owner, repo, run_id: runId
            });

            const headSha = run.head_sha;
            if (!headSha) {
              throw new Error("No head_sha on workflow_run.");
            }

            // 2) Tags holen und den Tag finden, dessen Commit auf head_sha zeigt
            // Hinweis: listTags -> t.commit.sha ist der Commit, auf den das Tag zeigt
            const allTags = [];
            let page = 1;
            while (true) {
              const { data } = await github.rest.repos.listTags({
                owner, repo, per_page: 100, page
              });
              if (!data.length) break;
              allTags.push(...data);
              page++;
            }

            const match = allTags.find(t => t.commit?.sha === headSha);
            if (!match) {
              // Fallback: Wenn der Upstream-Run ein Tag-Push war, ist head_branch oft schon der Tag-Name
              if (run.head_branch && /^v?\d+\.\d+\.\d+/.test(run.head_branch)) {
                core.setOutput("tag_name", run.head_branch);
              } else {
                throw new Error("Could not determine tag for head_sha " + headSha);
              }
            } else {
              core.setOutput("tag_name", match.name);
            }

      - name: "Create GitHub Release"
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ steps.extract_tag.outputs.tag_name }}
          name: ${{ steps.extract_tag.outputs.tag_name }}
          generate_release_notes: true
          files: |
            dist/*.whl
            dist/*.tar.gz
            dist/SHA256SUMS.txt