-
Notifications
You must be signed in to change notification settings - Fork 58
99 lines (88 loc) · 3.18 KB
/
release-package.yml
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
name: Package Release
on:
workflow_call:
inputs:
manifest-file-path:
required: true
type: string
aws-pkg-name:
required: true
type: string
jobs:
check-publish:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check_publish.outputs.version }}
publish: ${{ steps.check_publish.outputs.publish }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract Latest Tag
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release ls -L 1 --json "tagName" >> info.json
LATEST_TAG=$(cat info.json | jq -r '.[0].tagName')
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Check Publish
id: check_publish
env:
LATEST_TAG: ${{ env.LATEST_TAG }}
run: |
echo "latest_tag=$LATEST_TAG"
MANIFEST_VERSION=$(jq -r '.version' ${{ inputs.manifest-file-path }})
if [[ "$LATEST_TAG" == "$MANIFEST_VERSION" ]]; then
echo "publish=false" >> $GITHUB_OUTPUT
else
echo "publish=true" >> $GITHUB_OUTPUT
echo "version=$MANIFEST_VERSION" >> $GITHUB_OUTPUT
fi
get-latest-release:
runs-on: ubuntu-latest
if: needs.check-publish.outputs.publish == 'true'
needs: check-publish
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Get version from file
id: get_version
run: |
VERSION=$(jq -r '.version' ${{ inputs.manifest-file-path }})
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Use VERSION
run: |
echo "Version is ${{ env.VERSION }}"
- name: Extract release notes
id: extract-changelog
uses: sean0x42/markdown-extract@v2
with:
file: CHANGELOG.md
pattern: "[${{ env.VERSION }}]"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }} # Use the environment variable
release_name: Release ${{ env.VERSION }}
prerelease: false
draft: false
body: ${{ steps.extract-changelog.outputs.markdown }}
- name: Convert release notes to HTML
id: convert_to_html
uses: lifepal/[email protected]
with:
text: ${{ steps.extract-changelog.outputs.markdown }}
- name: Zip repository
run: |
zip -r ${{ inputs.aws-pkg-name }}.zip ${{ inputs.aws-pkg-name }}
- name: Setup AWS CLI
run: |
aws configure set aws_access_key_id ${{ secrets.PKG_S3_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.PKG_S3_ACCESS_KEY_SECRET }}
aws configure set region ${{ secrets.PKG_S3_REGION }}
- name: Upload to S3
run: |
aws s3 cp '${{ inputs.aws-pkg-name }}.zip' s3://zelthy3-packages/packages/${{ inputs.aws-pkg-name }}/${{ env.VERSION }}/ --acl public-read
aws s3 cp '${{ inputs.manifest-file-path }}' s3://zelthy3-packages/packages/${{ inputs.aws-pkg-name }}/${{ env.VERSION }}/ --acl public-read