File size: 2,535 Bytes
a301be7
 
 
 
 
 
 
15b0e38
a301be7
 
 
15b0e38
a301be7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15b0e38
a301be7
 
 
 
 
 
 
15b0e38
a301be7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
name: Releases
on:
  push:
    branches:
      - rolling

concurrency:
  group: "rolling-branch"

jobs:
  changelog:
    if: github.repository == 'neon-mmd/websurfx'
    runs-on: ubuntu-latest

    steps:
      # Create a temporary, uniquely named branch to push release info to
      - name: create temporary branch
        uses: peterjgrainger/[email protected]
        id: create-branch
        with:
          branch: "release-from-${{ github.sha }}"
          sha: "${{ github.sha }}"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # check out the repository afterwards
      - uses: actions/checkout@v3

      # fetch branches and switch to the temporary branch
      - name: switch to new branch
        run: git fetch --all && git checkout --track origin/release-from-${{ github.sha }}

      # update app config with version
      - name: get-npm-version
        id: package-version
        uses: martinbeentjes/npm-get-version-action@master
      - name: update app config
        run: sed -i 's/0.0.0/${{ steps.package-version.outputs.current-version}}/g' config/app.json

      # create release info and push it upstream
      - name: conventional Changelog Action
        id: changelog
        uses: TriPSs/conventional-changelog-action@v3
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          version-file: "./Cargo.toml"
          git-branch: "release-from-${{ github.sha }}"
          skip-on-empty: false
          skip-git-pull: true

      # create PR using GitHub CLI
      - name: create PR with release info
        id: create-pr
        run: gh pr create --base main --head release-from-${{ github.sha }} --title 'Merge new release into rolling' --body 'Created by Github action'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # merge PR using GitHub CLI
      - name: merge PR with release info
        id: merge-pr
        run: gh pr merge --admin --merge --subject 'Merge release info' --delete-branch
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # release info is now in main so we can continue as before
      - name: create release with last commit
        uses: actions/create-release@v1
        if: steps.changelog.outputs.skipped == 'false'
        env:
          GITHUB_TOKEN: ${{ secrets.CHANGELOG_RELEASE }}
        with:
          tag_name: ${{ steps.changelog.outputs.tag }}
          release_name: ${{ steps.changelog.outputs.tag }}
          body: ${{ steps.changelog.outputs.clean_changelog }}