-
Notifications
You must be signed in to change notification settings - Fork 20
102 lines (90 loc) · 3.68 KB
/
release.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
100
101
102
# This automation performs release tagging and artifact uploads of the LFS objects
# Contact SIG-Build for any issues or looking to make changes
name: Publish new release
on:
# Allows you to run this workflow manually from the Actions tag
workflow_dispatch:
inputs:
repository:
description: 'The repo to target for release'
required: true
type: choice
default: o3de
options:
- o3de
- o3de-atom-sampleviewer
- o3de-multiplayersample
- o3de-netsoaktest
release_tag:
description: 'The release tag'
required: true
type: string
release_notes_url:
description: 'The release notes url'
required: false
type: string
draft_release:
description: 'Stage release as draft. If unchecked, publish immediately'
default: true
required: true
type: boolean
run-name: Releasing ${{ inputs.repository }} for ${{ inputs.release_tag }}
jobs:
Publish:
name: Deploy
runs-on: ubuntu-latest
environment: ${{ github.ref_name }} # Check environment against branch
permissions:
contents: write
steps:
# Checkout the repository under $GITHUB_WORKSPACE, so the job can access it
- name: Checkout repo
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/${{ inputs.repository }}
ref: main
fetch-depth: 0
- name: Git LFS pull
run: |
git lfs install
git lfs fetch
- name: Get repo vars
id: vars
run: |
echo ::set-output name=latest_tag::$(git describe --tags `git rev-list --tags --max-count=1`)
echo ::set-output name=latest_main_sha::$(git log -n 1 --pretty=format:"%H" origin/main)
echo ::set-output name=archive_file::${{ inputs.repository }}-${{ inputs.release_tag }}-lfs
- name: Archive repo as compressed files
run: |
git archive -o ${{ steps.vars.outputs.archive_file }}.zip HEAD
git archive -o ${{ steps.vars.outputs.archive_file }}.tar.gz HEAD
- name: Split archive files if over limit
run: | # MAXSIZE = 2GB
MAXSIZE=2000000000
MAXSIZE_ZIP=2g
ARCFILE=${{ steps.vars.outputs.archive_file }}
if [ $(stat -c '%s' $ARCFILE.zip) -ge $MAXSIZE ]; then
mv $ARCFILE.zip temp-archive.zip && zip temp-archive.zip -s $MAXSIZE_ZIP --out $ARCFILE.zip
fi
if [ $(stat -c '%s' $ARCFILE.tar.gz) -ge $MAXSIZE ]; then
mv $ARCFILE.tar.gz temp-archive.tar.gz && split -b $MAXSIZE temp-archive.tar.gz $ARCFILE.tar.gz.part
fi
rm -f temp-archive.*
# Creates a release tag based on inputs
- name: Create Release
id: create_release
uses: ncipollo/[email protected]
with:
token: ${{ secrets.RELEASE_TOKEN }} # The RELEASE_TOKEN var is provided by the repo's Github environment secret to do cross repo actions
repo: ${{ inputs.repository }}
owner: ${{ github.repository_owner }}
name: ${{ inputs.release_tag }}
tag: ${{ inputs.release_tag }}
commit: ${{ steps.vars.outputs.latest_main_sha }}
body: |
## Release Notes
${{ inputs.release_notes_url }}
**Full Changelog**: https://github.com/${{ github.repository_owner }}/${{ inputs.repository }}/compare/${{ steps.vars.outputs.latest_tag }}...${{ inputs.release_tag }}
draft: ${{ inputs.draft_release }}
prerelease: false
artifacts: "${{ steps.vars.outputs.archive_file }}.*"