Skip to content

Commit e81715f

Browse files
committed
ci(actions): update CI
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
1 parent c01dbd4 commit e81715f

File tree

2 files changed

+111
-71
lines changed

2 files changed

+111
-71
lines changed

.github/workflows/release.yaml

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Release Version
8+
required: true
9+
app-version:
10+
description: PQTunnel App Version
11+
required: true
12+
endpoint-version:
13+
description: PQTunnel Endpoint Version
14+
required: true
15+
16+
env:
17+
CI: 1
18+
19+
jobs:
20+
populate-matrix:
21+
name: Populate matrix
22+
runs-on:
23+
- ubuntu-latest
24+
permissions:
25+
id-token: write
26+
contents: read
27+
outputs:
28+
matrix: ${{ steps.populate-matrix.outputs.matrix }}
29+
steps:
30+
- name: Configure AWS credentials
31+
uses: aws-actions/configure-aws-credentials@v4
32+
with:
33+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
34+
aws-region: ap-northeast-1
35+
36+
- name: List artifacts
37+
id: list-artifacts
38+
run: |
39+
app_artifacts=$(aws s3api list-objects --bucket aorta-chelpis --prefix build/aorta-app-installer/pq-tunnel-installer-${{github.event.inputs.app-version}} | jq -c)
40+
echo "app-artifacts=${app_artifacts}" >> "$GITHUB_OUTPUT"
41+
endpoint_artifacts=$(aws s3api list-objects --bucket aorta-chelpis --prefix build/aorta-endpoint-installer/pqtunnel-endpoint-v${{github.event.inputs.endpoint-version}} | jq -c)
42+
echo "endpoint-artifacts=${endpoint_artifacts}" >> "$GITHUB_OUTPUT"
43+
44+
- name: Populate matrix
45+
id: populate-matrix
46+
uses: actions/github-script@v6
47+
with:
48+
script: |
49+
const APP_NAME = "pqtunnel-app";
50+
const APP_KEY_REGEX = /^build\/aorta-app-installer\/pq-tunnel-installer-(.*)$/;
51+
const ENDPOINT_NAME = "pqtunnel-endpoint";
52+
const ENDPOINT_KEY_REGEX =
53+
/^build\/aorta-endpoint-installer\/pqtunnel-endpoint-v(.*)$/;
54+
const appArtifacts = ${{ steps.list-artifacts.outputs.app-artifacts }};
55+
const endpointArtifacts = ${{ steps.list-artifacts.outputs.endpoint-artifacts }};
56+
const processArtifact = (artifacts, prefix, regex) =>
57+
artifacts.Contents.flatMap(({ Key }) => {
58+
const match = regex.exec(Key);
59+
if (match && match[1] && !match[1].includes("-dev-") && !match[1].includes("-alpha-") && !match[1].includes("-beta-")) {
60+
return [
61+
{
62+
name: `${prefix}-${match[1]}`,
63+
key: Key,
64+
},
65+
];
66+
}
67+
return [];
68+
});
69+
core.setOutput("matrix", {
70+
include: processArtifact(appArtifacts, APP_NAME, APP_KEY_REGEX).concat(
71+
processArtifact(endpointArtifacts, ENDPOINT_NAME, ENDPOINT_KEY_REGEX),
72+
),
73+
});
74+
75+
publish-release:
76+
name: Publish release
77+
runs-on:
78+
- ubuntu-latest
79+
needs:
80+
- populate-matrix
81+
permissions:
82+
id-token: write
83+
contents: write
84+
strategy:
85+
fail-fast: false
86+
matrix: ${{ fromJson(needs.populate-matrix.outputs.matrix) }}
87+
steps:
88+
- name: Configure AWS credentials
89+
uses: aws-actions/configure-aws-credentials@v4
90+
with:
91+
role-to-assume: arn:aws:iam::442277771319:role/PQTunnelArtifactReadOnly
92+
aws-region: ap-northeast-1
93+
94+
- name: Download artifact
95+
run: |
96+
echo "⬇️ Downloading ${{ matrix.name }}"
97+
aws s3api get-object --bucket aorta-chelpis --key ${{ matrix.key }} ${{ matrix.name }}
98+
99+
- name: Upload Release
100+
uses: softprops/action-gh-release@v1
101+
with:
102+
name: Release ${{ github.event.inputs.version }}
103+
tag_name: ${{ github.event.inputs.version }}
104+
files: ${{ matrix.name }}
105+
append_body: true
106+
107+
- name: Post Download artifact
108+
uses: actions/github-script@v6
109+
with:
110+
script: |
111+
await io.rmRF('${{ matrix.name }}');

.github/workflows/release.yml

-71
This file was deleted.

0 commit comments

Comments
 (0)