-
Notifications
You must be signed in to change notification settings - Fork 150
151 lines (136 loc) · 5.36 KB
/
update_licenses.yaml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Workflow to update licenses for Ubuntu, macOS Silicon and macOS intel
name: Update licenses
on:
workflow_dispatch:
inputs:
linux:
description: "Update licenses for Ubuntu"
type: boolean
required: false
default: true
mac_silicon:
description: "Update licenses for macOS (silicon)"
type: boolean
required: false
default: true
mac_intel:
description: "Update licenses for macOS (intel)"
type: boolean
required: false
default: true
concurrency:
group: "${{ github.ref }}-${{ github.event_name }}-${{ github.workflow }}"
cancel-in-progress: true
jobs:
# Update licenses for all selected OS
# The matrix strategy trick is inspired from https://github.com/orgs/community/discussions/26253
# Basically, GitHub does not allow to have conditional statements when building matrices. One way
# to do it is to add new boolean fields and exclude the os config(s) by combining them together.
update_licenses:
strategy:
matrix:
config:
- os_name: linux
os: ubuntu-latest
- os_name: mac_silicon
os: macos-latest-xlarge
- os_name: mac_intel
os: macos-latest-large
triggerLinux:
- ${{ inputs.linux }}
triggerMacSilicon:
- ${{ inputs.mac_silicon }}
triggerMacIntel:
- ${{ inputs.mac_intel }}
exclude:
- triggerLinux: false
config: {os_name: linux, os: ubuntu-latest}
- triggerMacSilicon: false
config: {os_name: mac_silicon, os: macos-latest-xlarge}
- triggerMacIntel: false
config: {os_name: mac_intel, os: macos-latest-large}
fail-fast: false
runs-on: ${{ matrix.config.os }}
defaults:
run:
shell: bash
env:
PIP_INDEX_URL: ${{ secrets.PIP_INDEX_URL }}
steps:
# Mask internal URLs if logged
- name: Add masks
id: masks
run: |
echo "::add-mask::${{ secrets.INTERNAL_PYPI_URL_FOR_MASK }}"
echo "::add-mask::${{ secrets.INTERNAL_REPO_URL_FOR_MASK }}"
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
token: ${{ secrets.BOT_TOKEN }}
# Set up python 3.10 because Github does not seem to provide support for python 3.8 on arm64
# List of available versions and architectures :
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
- name: Set up Python 3.10
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry==1.8.4
make setup_env
- name: Update licenses
run: |
make licenses
# Upload the updated license files as artifacts, if they exist
# It is possible that no files have been generated if licenses have already been done for some
# configuration(s)
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
if-no-files-found: ignore
name: licenses_${{ matrix.config.os_name }}
path: |
deps_licenses/licenses_${{ matrix.config.os_name }}_user.txt
deps_licenses/licenses_${{ matrix.config.os_name }}_user.txt.md5
# Push the updates license files, as a PR or directly to the branch
push_licenses:
runs-on: ubuntu-latest
needs: [update_licenses]
if: always()
steps:
# Mask internal URLs if logged
- name: Add masks
id: masks
run: |
echo "::add-mask::${{ secrets.INTERNAL_PYPI_URL_FOR_MASK }}"
echo "::add-mask::${{ secrets.INTERNAL_REPO_URL_FOR_MASK }}"
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
token: ${{ secrets.BOT_TOKEN }}
# Retrieve all updated license files
# Enable 'merge-multiple' to download all files in the 'deps_licenses' directory
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: deps_licenses/
merge-multiple: true
# If the target branch is main or a release branch, a pull request is opened for everyone to
# review
- name: Open PR
if: ${{ github.ref_name == 'main' || startsWith(github.ref_name , 'release/') }}
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: "chore: update licenses"
branch: "chore/update_licenses"
base: "${{ github.ref_name }}"
title: "Update licenses in ${{ github.ref_name }}"
body: "Update licenses in ${{ github.ref_name }}"
# If the target branch is another branch, the current branch is automatically merged into it
- name: Push changes into the current branch
if: ${{ github.ref_name != 'main' && !(startsWith(github.ref_name , 'release/')) }}
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 #v5.0.1
with:
commit_message: "chore: update licenses"
add_options: '-u'