Debian Codegraph @

.github/workflows/sourcecode-release.yaml

raw
1 name: Source Code - Release
2
3 on:
4 push:
5 tags:
6 - "v*"
7
8 permissions:
9 contents: read
10
11 jobs:
12 goreleaser:
13 runs-on: ubuntu-latest
14 permissions:
15 contents: write # Grant write permissions to repository contents
16 issues: write # Grant write permissions to PR milestones
17 steps:
18 - name: Checkout Repo
19 uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
20 with:
21 fetch-depth: 0
22
23 # Extract title from latest version title in CHANGELOG.md
24 - name: Prepare release title
25 id: release-title
26 run: |
27 echo "title=$(grep -A 2 '<!-- next version -->' CHANGELOG.md | awk '/##/{print $2}')" >> $GITHUB_OUTPUT
28
29 - name: Prepare release notes
30 run: |
31 touch release-notes.md
32 echo "### Images and binaries here: https://github.com/open-telemetry/opentelemetry-collector-releases/releases/tag/${{ github.ref_name }}" >> release-notes.md
33 echo "" >> release-notes.md
34 echo "## End User Changelog" >> release-notes.md
35
36 awk '/<!-- next version -->/,/<!-- previous-version -->/' CHANGELOG.md > tmp-chlog.md # select changelog of latest version only
37 sed '1,3d' tmp-chlog.md >> release-notes.md # delete first 3 lines of file
38
39 echo "" >> release-notes.md
40 echo "## API Changelog" >> release-notes.md
41
42 awk '/<!-- next version -->/,/<!-- previous-version -->/' CHANGELOG-API.md > tmp-chlog-api.md # select changelog of latest version only
43 sed '1,3d' tmp-chlog-api.md >> release-notes.md # delete first 3 lines of file
44
45 - name: Create Github Release
46 run: |
47 gh release create ${{ github.ref_name }} -t ${{ steps.release-title.outputs.title }} -F release-notes.md
48 env:
49 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
51 with:
52 script: |
53 const milestones = await github.rest.issues.listMilestones({
54 owner: context.repo.owner,
55 repo: context.repo.repo,
56 state: "open"
57 })
58 for (const milestone of milestones.data) {
59 if (milestone.title == "next release") {
60 await github.rest.issues.updateMilestone({
61 owner: context.repo.owner,
62 repo: context.repo.repo,
63 milestone_number: milestone.number,
64 title: "${{ github.ref_name }}"
65 });
66 await github.rest.issues.createMilestone({
67 owner: context.repo.owner,
68 repo: context.repo.repo,
69 title: "next release"
70 });
71 return
72 }
73 }