Repository navigation
109 lines (94 loc) · 3.4 KB
/
Copy pathprerelease.yml
File metadata and controls
109 lines (94 loc) · 3.4 KB
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
name: Prerelease
on:
workflow_call:
secrets:
token:
required: true
jobs:
create_prerelease:
if: github.repository == 'official-clockwork/Clockwork' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Get Commit SHA of Latest Pre-release
run: |
# Install required packages
sudo apt-get update
sudo apt-get install -y curl jq
echo "COMMIT_SHA_TAG=$(jq -r 'map(select(.prerelease)) | first | .tag_name' <<< $(curl -s https://api.github.com/repos/${{ github.repository_owner }}/Clockwork/releases))" >> $GITHUB_ENV
- name: Remove Outdated Pre-release
run: gh release delete ${{ env.COMMIT_SHA_TAG }} --cleanup-tag
if: env.COMMIT_SHA_TAG != 'null'
env:
GITHUB_TOKEN: ${{ secrets.token }}
- name: Check Pullable Commits
id: check_commits
run: |
git fetch
CHANGES=$(git rev-list HEAD..origin/main --count)
echo "CHANGES=$CHANGES" >> $GITHUB_ENV
- name: Get last commit SHA
id: last_commit
run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
- name: Get commit date
id: commit_date
run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
- name: Create Prerelease
if: github.ref_name == 'main' && env.CHANGES == '0'
uses: softprops/action-gh-release@v2
with:
name: Clockwork dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
tag_name: clockwork-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
prerelease: true
files: LICENSE
env:
GITHUB_TOKEN: ${{ secrets.token }}
upload_binaries:
needs: [create_prerelease]
strategy:
fail-fast: false
matrix:
os:
- platform: linux
extension: ''
- platform: windows
extension: '.exe'
arch:
- x86-64-v3
- znver4
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: clockwork-${{ matrix.os.platform }}-${{ matrix.arch }}
path: artifacts
- name: Check Pullable Commits
id: check_commits
run: |
git fetch
CHANGES=$(git rev-list HEAD..origin/main --count)
echo "CHANGES=$CHANGES" >> $GITHUB_ENV
- name: Get last commit SHA
id: last_commit
run: echo "COMMIT_SHA=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
- name: Get commit date
id: commit_date
run: echo "COMMIT_DATE=$(git show -s --date=format:'%Y%m%d' --format=%cd HEAD)" >> $GITHUB_ENV
- name: Create Prerelease
if: github.ref_name == 'main' && env.CHANGES == '0'
uses: softprops/action-gh-release@v2
with:
name: Clockwork dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
tag_name: clockwork-dev-${{ env.COMMIT_DATE }}-${{ env.COMMIT_SHA }}
prerelease: true
files: artifacts/clockwork-${{ matrix.os.platform }}-${{ matrix.arch }}${{ matrix.os.extension }}
env:
GITHUB_TOKEN: ${{ secrets.token }}