summaryrefslogtreecommitdiff
path: root/.github/workflows/prepare-release-dependencies.yml
blob: daf34dfcd842e2d9ddd56f2073b7b9b95519063f (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Prepare Release Dependencies
run-name: Prepare Release Dependencies ${{ inputs.source_branch }} ${{ inputs.generation }}

on:
  workflow_dispatch:
    inputs:
      source_branch:
        description: Protected develop or release/X.Y branch whose recipes to validate
        required: true
        type: string
      generation:
        description: Explicit validated-build-YYYYMMDD-RUN-ATTEMPT image generation
        required: true
        type: string

permissions:
  contents: read

concurrency:
  group: prepare-release-dependencies
  cancel-in-progress: false

jobs:
  prepare:
    if: github.repository == 'WSJTX/wsjtx-internal' && github.ref == 'refs/heads/develop'
    runs-on: ubuntu-24.04
    timeout-minutes: 60
    permissions:
      contents: read
      packages: write
    steps:
      - name: Require protected develop
        env:
          REF_PROTECTED: ${{ github.ref_protected }}
        run: |
          if [ "$REF_PROTECTED" != true ]; then
            echo "::error::develop is not protected"
            exit 1
          fi
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Resolve protected source branch to an exact commit
        id: source
        env:
          GH_TOKEN: ${{ github.token }}
          SOURCE_BRANCH: ${{ inputs.source_branch }}
        shell: bash
        run: |
          if [[ ! "$SOURCE_BRANCH" =~ ^(develop|release/[0-9]+\.[0-9]+)$ ]]; then
            echo "::error::Select develop or a release/X.Y branch"
            exit 1
          fi
          branch="$(gh api "repos/${GITHUB_REPOSITORY}/branches/${SOURCE_BRANCH//\//%2F}")"
          if [ "$(jq -r '.protected' <<< "$branch")" != true ]; then
            echo "::error::$SOURCE_BRANCH is not protected"
            exit 1
          fi
          sha="$(jq -r '.commit.sha' <<< "$branch")"
          [[ "$sha" =~ ^[0-9a-f]{40}$ ]]
          echo "sha=$sha" >> "$GITHUB_OUTPUT"
      - name: Check out source recipes
        uses: actions/checkout@v7
        with:
          ref: ${{ steps.source.outputs.sha }}
          path: source
          persist-credentials: false
      - name: Install registry tools
        run: |
          sudo apt-get update
          sudo apt-get install -y skopeo
      - uses: docker/setup-qemu-action@v4
        with:
          image: tonistiigi/binfmt:qemu-v10.2.3-68@sha256:400a4873b838d1b89194d982c45e5fb3cda4593fbfd7e08a02e76b03b21166f0
          platforms: arm64,arm
      - name: Authenticate registry clients
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          printf '%s' "$GH_TOKEN" | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
          printf '%s' "$GH_TOKEN" | skopeo login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
      - name: Verify and copy the selected images
        working-directory: source
        env:
          GENERATION: ${{ inputs.generation }}
          PREPARATION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
        run: |
          python3 ../.github/scripts/release-linux-images.py prepare "$GENERATION" \
            --output-directory ../prepared-dependencies
          {
            echo '## Prepared Linux dependencies'
            echo
            echo 'Review and commit release-linux-images.json before creating the candidate.'
            echo
            echo '```json'
            cat ../prepared-dependencies/release-linux-images.json
            echo '```'
          } >> "$GITHUB_STEP_SUMMARY"
      - uses: actions/upload-artifact@v7
        with:
          name: prepared-release-dependencies
          path: prepared-dependencies/
          if-no-files-found: error
          retention-days: 90