music-assistant-server

4 KBYML
auto-release.yml
4 KB126 lines • yaml
1name: Auto Release
2
3# Automatically creates releases with proper version increments.
4# - Nightly: runs at 05:00 Europe/Amsterdam with 2+ commits
5# - Beta, RC, stable: manually triggered
6
7on:
8  schedule:
9    - cron: "0 5 * * *"
10      timezone: "Europe/Amsterdam"
11  workflow_dispatch:
12    inputs:
13      channel:
14        description: "Release channel"
15        required: true
16        type: choice
17        options:
18          - nightly
19          - beta
20          - rc
21          - stable
22        default: nightly
23      important_notes:
24        description: "Important notes (breaking changes, critical info, etc.)"
25        required: false
26
27permissions:
28  contents: read
29
30concurrency:
31  group: auto-release-${{ inputs.channel || 'nightly' }}
32  cancel-in-progress: false
33
34jobs:
35  resolve-release:
36    name: Resolve release source and version
37    runs-on: ubuntu-latest
38    outputs:
39      version: ${{ steps.version.outputs.version }}
40      should_release: ${{ steps.version.outputs.should_release }}
41      channel: ${{ steps.channel.outputs.channel }}
42      branch: ${{ steps.branch.outputs.branch }}
43      source_sha: ${{ steps.source.outputs.sha }}
44    steps:
45      - name: Check out release workflow
46        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
47        with:
48          ref: ${{ github.workflow_sha }}
49          path: .release-workflow
50          persist-credentials: false
51
52      - name: Set release channel
53        id: channel
54        env:
55          DISPATCH_CHANNEL: ${{ inputs.channel }}
56          EVENT_NAME: ${{ github.event_name }}
57        run: |
58          if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
59            channel="$DISPATCH_CHANNEL"
60          else
61            channel="nightly"
62          fi
63          echo "channel=$channel" >> "$GITHUB_OUTPUT"
64          echo "Release channel: $channel"
65
66      - name: Resolve source branch
67        id: branch
68        run: >-
69          python3 .release-workflow/scripts/release_workflow.py branch
70          --channel "${{ steps.channel.outputs.channel }}"
71          --github-output "$GITHUB_OUTPUT"
72
73      - name: Check out release source
74        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
75        with:
76          ref: ${{ steps.branch.outputs.branch }}
77          fetch-depth: 0
78          path: source
79          persist-credentials: false
80
81      - name: Capture source commit
82        id: source
83        run: |
84          source_sha=$(git -C source rev-parse HEAD)
85          echo "sha=$source_sha" >> "$GITHUB_OUTPUT"
86          echo "Release source: ${{ steps.branch.outputs.branch }}@$source_sha"
87
88      - name: Calculate next version
89        id: version
90        working-directory: source
91        run: >-
92          python3 ../.release-workflow/scripts/release_workflow.py auto-version
93          --channel "${{ steps.channel.outputs.channel }}"
94          --source-sha "${{ steps.source.outputs.sha }}"
95          --github-output "$GITHUB_OUTPUT"
96
97      - name: Log release decision
98        env:
99          CHANNEL: ${{ steps.channel.outputs.channel }}
100          COMMITS_SINCE: ${{ steps.version.outputs.commits_since }}
101          SHOULD_RELEASE: ${{ steps.version.outputs.should_release }}
102          VERSION: ${{ steps.version.outputs.version }}
103        run: |
104          if [ "$SHOULD_RELEASE" = "true" ]; then
105            echo "Will create $CHANNEL release $VERSION from $COMMITS_SINCE new commit(s)"
106          else
107            echo "Skipping $CHANNEL release with only $COMMITS_SINCE new commit(s)"
108          fi
109
110  trigger-release:
111    name: Create release
112    needs: resolve-release
113    if: needs.resolve-release.outputs.should_release == 'true'
114    permissions:
115      contents: write
116      packages: write
117      pull-requests: read
118    uses: ./.github/workflows/release.yml
119    with:
120      version: ${{ needs.resolve-release.outputs.version }}
121      channel: ${{ needs.resolve-release.outputs.channel }}
122      source_sha: ${{ needs.resolve-release.outputs.source_sha }}
123      important_notes: ${{ inputs.important_notes }}
124    secrets:
125      MUSIC_ASSISTANT_BOT_PRIVATE_KEY: ${{ secrets.MUSIC_ASSISTANT_BOT_PRIVATE_KEY }}
126