1name: Kernel-Auto-Release
2
3on:
4  workflow_dispatch:
5    inputs:
6      commit_id:
7        description: 'Commit ID'
8        required: true
9        default: 'HEAD'
10      version_number:
11        description: 'Version Number (Ex. 10.4.4)'
12        required: true
13        default: '10.4.4'
14      main_br_version:
15        description: "Version String for task.h on main branch (leave empty to leave as-is)."
16        required: false
17        default: ''
18
19jobs:
20  release-packager:
21    name: Release Packager
22    runs-on: ubuntu-latest
23    steps:
24      # Install python 3
25      - name: Tool Setup
26        uses: actions/setup-python@v2
27        with:
28          architecture:   x64
29        env:
30          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31
32      # Currently FreeRTOS/.github/scripts houses the release script. Download it for upcoming usage
33      - name: Checkout FreeRTOS Release Tools
34        uses: actions/checkout@v4.1.1
35        with:
36          repository: FreeRTOS/FreeRTOS
37          path: tools
38
39      # Simpler git auth if we use checkout action and forward the repo to release script
40      - name: Checkout FreeRTOS Kernel
41        uses: actions/checkout@v4.1.1
42        with:
43          path: local_kernel
44          fetch-depth: 0
45
46      - name: Configure git identity
47        run: |
48          git config --global user.name ${{ github.actor }}
49          git config --global user.email ${{ github.actor }}@users.noreply.github.com
50
51      - name: create a new branch that references commit id
52        working-directory: ./local_kernel
53        run: |
54          git checkout -b ${{ github.event.inputs.version_number }} ${{ github.event.inputs.commit_id }}
55          echo "COMMIT_SHA_1=$(git rev-parse HEAD)" >> $GITHUB_ENV
56
57      - name: Update source files with version info
58        run: |
59          # Install deps and run
60          pip install -r ./tools/.github/scripts/release-requirements.txt
61          ./tools/.github/scripts/update_src_version.py FreeRTOS --kernel-repo-path=local_kernel --kernel-commit=${{ env.COMMIT_SHA_1 }} --new-kernel-version=${{ github.event.inputs.version_number }} --new-kernel-main-br-version=${{ github.event.inputs.main_br_version }}
62          exit $?
63        env:
64            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65
66      - name : Update version number in manifest.yml
67        working-directory: ./local_kernel
68        run: |
69          ./.github/scripts/manifest_updater.py -v ${{ github.event.inputs.version_number }}
70          exit $?
71
72      - name : Commit version number change in manifest.yml
73        working-directory: ./local_kernel
74        run: |
75          git add .
76          git commit -m '[AUTO][RELEASE]: Update version number in manifest.yml'
77          git push -u origin ${{ github.event.inputs.version_number }}
78
79      - name: Generate SBOM
80        uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main
81        with:
82          repo_path: ./local_kernel
83          source_path: ./
84
85      - name: commit SBOM file
86        working-directory: ./local_kernel
87        run: |
88          git add .
89          git commit -m '[AUTO][RELEASE]: Update SBOM'
90          git push -u origin ${{ github.event.inputs.version_number }}
91          echo "COMMIT_SHA_2=$(git rev-parse HEAD)" >> $GITHUB_ENV
92
93      - name: Release
94        run: |
95          # Install deps and run
96          pip install -r ./tools/.github/scripts/release-requirements.txt
97          ./tools/.github/scripts/release.py ${{ github.repository_owner }} --kernel-repo-path=local_kernel --kernel-commit=${{ env.COMMIT_SHA_2 }} --new-kernel-version=${{ github.event.inputs.version_number }} --new-kernel-main-br-version=${{ github.event.inputs.main_br_version }}
98          exit $?
99        env:
100            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101
102      - name: Cleanup
103        working-directory: ./local_kernel
104        run: |
105          # Delete the branch created for Tag by SBOM generator
106          git push -u origin --delete ${{ github.event.inputs.version_number }}
107