Skip to content

Commit 9e92e0e

Browse files
authored
Update certbot version; add GH actions build (#2)
* Update certbot version; add GH actions build * python 3.13
1 parent 6186171 commit 9e92e0e

File tree

4 files changed

+177
-73
lines changed

4 files changed

+177
-73
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 2
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.cs]
11+
indent_size = 4
12+
13+
[*.{csv,editorconfig,cs,config,sql}]
14+
insert_final_newline = false

.github/workflows/build.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Build Certbot Lambda Package
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
setup-build-workflow:
12+
runs-on: ubuntu-latest
13+
14+
outputs:
15+
IS_PRERELEASE: ${{ steps.set-vars.outputs.IS_PRERELEASE }}
16+
IS_MERGE_TO_MAIN: ${{ steps.set-vars.outputs.IS_MERGE_TO_MAIN }}
17+
IS_MERGE_TO_DEVELOP: ${{ steps.set-vars.outputs.IS_MERGE_TO_DEVELOP }}
18+
REF_TO_BUILD_AND_TAG: ${{ steps.set-vars.outputs.REF_TO_BUILD_AND_TAG }}
19+
IS_DEPENDABOT_PR: ${{ steps.actor_check.outputs.IS_DEPENDABOT_PR }}
20+
21+
steps:
22+
- name: Set default env variables
23+
id: set-vars
24+
uses: actions/github-script@v7
25+
with:
26+
script: |
27+
const targetRef = '${{ github.base_ref }}';
28+
const sourceRef = '${{ github.head_ref }}';
29+
const mergeRef = '${{ github.ref }}';
30+
31+
const prIsDraft = '${{ github.event.pull_request.draft }}' === 'true';
32+
const prMergedToMain = mergeRef === 'refs/heads/master';
33+
34+
const isPreRelease = !prMergedToMain
35+
36+
// For a detailed explanation of why we use different refs for different scenarios
37+
// see https://docs.github.com/en/rest/reference/pulls#get-a-pull-request
38+
const refToBuildAndTag = isPreRelease ? sourceRef : mergeRef;
39+
40+
Object.entries({
41+
IS_PRERELEASE: isPreRelease,
42+
IS_MERGE_TO_MAIN: prMergedToMain,
43+
REF_TO_BUILD_AND_TAG: refToBuildAndTag,
44+
}).forEach(pair => {
45+
core.setOutput(...pair);
46+
console.info(...pair);
47+
});
48+
49+
- name: Check if Dependabot PR
50+
id: actor_check
51+
uses: actions/github-script@v7
52+
with:
53+
script: |
54+
const actor = '${{ github.actor}}';
55+
const knownDependabotNames = [
56+
'dependabot[bot]',
57+
'dependabot'
58+
];
59+
const isDependabotPR = knownDependabotNames.includes(actor);
60+
core.info(`Is Dependabot PR: ${isDependabotPR}`);
61+
core.setOutput('IS_DEPENDABOT_PR', isDependabotPR);
62+
63+
get-version:
64+
runs-on: ubuntu-latest
65+
needs: setup-build-workflow
66+
67+
outputs:
68+
NEXT_VERSION: ${{ steps.get-version.outputs.NEXT_VERSION }}
69+
NEXT_VERSION_NO_PREFIX: ${{ steps.get-version.outputs.NEXT_VERSION_NO_PREFIX }}
70+
71+
steps:
72+
- uses: actions/checkout@v5
73+
with:
74+
fetch-depth: 0 # Includes all history for all branches and tags
75+
76+
- id: get-version
77+
uses: joemcbride/[email protected]
78+
with:
79+
calculate-prerelease-version: ${{ needs.setup-build-workflow.outputs.IS_PRERELEASE }}
80+
branch-name: ${{ needs.setup-build-workflow.outputs.REF_TO_BUILD_AND_TAG }}
81+
tag-prefix: certbot-
82+
fallback-to-no-prefix-search: false
83+
default-release-type: minor
84+
create-ref: true
85+
github-token: ${{ secrets.GITHUB_TOKEN }}
86+
87+
- run: |
88+
echo "The next version is ${{ env.NEXT_VERSION }}"
89+
echo "The next version without the prefix is ${{ env.NEXT_VERSION_NO_PREFIX }}"
90+
91+
build:
92+
runs-on: ubuntu-latest
93+
needs: get-version
94+
permissions:
95+
id-token: write
96+
contents: read
97+
env:
98+
CI: true
99+
AWS_REGION: us-west-2
100+
NEXT_VERSION: ${{ needs.get-version.outputs.NEXT_VERSION }}
101+
NEXT_VERSION_NO_PREFIX: ${{ needs.get-version.outputs.NEXT_VERSION_NO_PREFIX }}
102+
NEXT_BUILD_VERSION: ${{ needs.get-version.outputs.NEXT_BUILD_VERSION }}
103+
104+
steps:
105+
- name: Checkout code
106+
uses: actions/checkout@v5
107+
108+
- name: Set up Python
109+
uses: actions/setup-python@v6
110+
with:
111+
python-version: '3.13'
112+
113+
- name: Run package script
114+
run: ./package.sh
115+
116+
- name: Show package size
117+
run: |
118+
echo "Package size:"
119+
du -h certbot/certbot-lambda.zip || echo "certbot-lambda.zip not found"
120+
121+
- name: Upload build artifacts
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: certbot-lambda-package
125+
path: certbot/certbot-lambda.zip
126+
retention-days: 30
127+
128+
- name: Configure AWS Credentials
129+
uses: aws-actions/configure-aws-credentials@v5
130+
with:
131+
role-to-assume: arn:aws:iam::888985673581:role/GithubActions-DovetailSofware_Org-OIDC
132+
role-session-name: GitHub_to_AWS_via_FederatedOIDC
133+
aws-region: ${{ env.AWS_REGION }}
134+
135+
- name: Upload Certbot Lambda Assets to S3
136+
working-directory: certbot
137+
run: |
138+
aws s3 cp . s3://jenkins-artifacts.us-west-2.dovetailnow.com/jobs/certbot-lambda/$NEXT_VERSION_NO_PREFIX --recursive --exclude "*" --include "*.zip"

package.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,32 @@ set -e
44

55
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
readonly CERTBOT_VERSION=$( awk -F= '$1 == "certbot"{ print $NF; }' "${SCRIPT_DIR}/requirements.txt" )
7-
readonly VENV="certbot/venv"
8-
readonly PYTHON="python3"
9-
readonly CERTBOT_ZIP_FILE="certbot.zip"
10-
readonly CERTBOT_SITE_PACKAGES=${VENV}/Lib/site-packages
7+
VENV="certbot/venv"
8+
readonly PYTHON="python"
9+
readonly CERTBOT_ZIP_FILE="certbot-lambda.zip"
10+
CERTBOT_SITE_PACKAGES=${VENV}/lib/site-packages
11+
12+
readonly CI=$CI
1113

1214
cd "${SCRIPT_DIR}"
1315

14-
${PYTHON} -m venv "${VENV}"
15-
source "${VENV}/Scripts/activate"
16+
if [ "${CI}" = true ]; then
17+
echo "Running in CI mode"
18+
${PYTHON} -m venv $VENV
19+
VENV=$GITHUB_WORKSPACE/$VENV
20+
source $VENV/bin/activate
21+
CERTBOT_SITE_PACKAGES=${VENV}/lib/python3.13/site-packages
22+
else
23+
echo "Running in local mode"
24+
rm -rf ./certbot
25+
${PYTHON} -m venv "${VENV}"
26+
source "${VENV}/Scripts/activate"
27+
fi
1628

17-
pip3 install -r requirements.txt
29+
pip install -r requirements.txt
1830

1931
pushd ${CERTBOT_SITE_PACKAGES}
20-
zip -r -q ${SCRIPT_DIR}/certbot/${CERTBOT_ZIP_FILE} . -x "/*__pycache__/*"
32+
7z a -tzip ${SCRIPT_DIR}/certbot/${CERTBOT_ZIP_FILE} . -xr!__pycache__
2133
popd
2234

23-
zip -g "certbot/${CERTBOT_ZIP_FILE}" main.py
35+
7z a -tzip "certbot/${CERTBOT_ZIP_FILE}" main.py

requirements.txt

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,4 @@
1-
acme==2.9.0
2-
apispec==6.3.0
3-
awscli==1.32.52
4-
awscli-local==0.22.0
5-
boto3==1.34.52
6-
botocore==1.34.52
7-
cachetools==5.0.0
8-
certbot==2.9.0
9-
certbot-dns-route53==2.9.0
10-
certbot-dns-tencentcloud==2.0.2
11-
certifi==2023.7.22
12-
cffi==1.15.1
13-
charset-normalizer==3.1.0
14-
click==8.1.3
15-
colorama==0.4.4
16-
ConfigArgParse==1.7
17-
configobj==5.0.8
18-
cryptography==42.0.5
19-
dill==0.3.6
20-
distro==1.9.0
21-
dnslib==0.9.23
22-
dnspython==2.3.0
23-
docutils==0.16
24-
ecdsa==0.18.0
25-
idna==3.4
26-
jmespath==1.0.1
27-
josepy==1.14.0
28-
lark==1.1.5
29-
localstack-client==2.5
30-
markdown-it-py==2.2.0
31-
mdurl==0.1.2
32-
packaging==23.1
33-
parsedatetime==2.6
34-
pbr==5.11.1
35-
pcore==0.2.1
36-
plux==1.5.0
37-
psh==0.2.12
38-
psutil==5.9.5
39-
psys==0.4.2
40-
pyaes==1.6.1
41-
pyasn1==0.5.0
42-
pycparser==2.21
43-
Pygments==2.15.1
44-
pyOpenSSL==24.0.0
45-
pyRFC3339==1.1
46-
python-dateutil==2.8.2
47-
python-dotenv==1.0.0
48-
python-hcl2==4.3.0
49-
python-jose==3.3.0
50-
pytz==2024.1
51-
pywin32==306
52-
PyYAML==6.0.1
53-
requests==2.31.0
54-
rich==13.3.4
55-
rsa==4.7.2
56-
s3transfer==0.10.0
57-
semver==3.0.0
58-
six==1.16.0
59-
stevedore==5.0.0
60-
tabulate==0.9.0
61-
tailer==0.4.1
62-
terraform-local==0.16.0
63-
urllib3==2.0.7
64-
windows-curses==2.3.2
1+
boto3==1.40.48
2+
certbot==5.1.0
3+
certbot-dns-route53==5.1.0
4+
cryptography==46.0.2

0 commit comments

Comments
 (0)