generated from sarioglu/svelte-tailwindcss-template
-
Notifications
You must be signed in to change notification settings - Fork 4
129 lines (110 loc) · 4.38 KB
/
nightly-matrix.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: 🦇 Nightly build
on:
push:
branches:
- "**"
tags-ignore:
- "*"
jobs:
prepare-version:
runs-on: ubuntu-latest
outputs:
versionOverride: ${{ steps.get-version.outputs.versionOverride }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Read current version and append date
id: get-version
run: |
# Extract current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
# Append date-based patch string
VERSION_OVERRIDE=$(date +"${CURRENT_VERSION}-nightly.1.%Y%m%d.%-H%M")
# Export as output
echo "versionOverride=$VERSION_OVERRIDE" >> "$GITHUB_OUTPUT"
matrix-build:
needs: prepare-version
uses: ./.github/workflows/build-matrix.yml
with:
exportScript: export:nightly
versionOverride: ${{ needs.prepare-version.outputs.versionOverride }}
secrets: inherit
publish-nightly-release:
runs-on: ubuntu-latest
needs: matrix-build
if: ${{ github.ref == 'refs/heads/stable' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-tags: true
fetch-depth: 0
- name: Read version from package.json
id: get_version
run: |
version=$(cat package.json | jq -r '.version')
tag_name="v${version}-nightly"
echo "Tag name: $tag_name"
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT
- name: Delete all releases by name
id: delete_releases_by_name
run: |
release_name="Release Nightly Version" # Replace with the release name you want to delete
echo "Deleting all releases with the name: $release_name"
# Fetch all releases
releases=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases")
# Find and delete all releases matching the given name
echo "$releases" | jq -c --arg release_name "$release_name" '.[] | select(.name == $release_name) | .id' | while read release_id; do
echo "Deleting release with ID: $release_id"
# Delete the release by ID
curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/$release_id"
echo "Deleted release with ID: $release_id"
done
- name: Remove Nightly Tags
run: |
# Configure Git
echo "Configuring Git..."
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Get all tags containing "-nightly"
echo "Retrieving all tags containing '-nightly'..."
nightly_tags=$(git tag -l "*-nightly")
echo "Nightly tags found: $nightly_tags"
# Loop through each nightly tag and delete it locally and remotely
if [ -z "$nightly_tags" ]; then
echo "No nightly tags found. Exiting..."
else
for tag in $nightly_tags; do
echo "Deleting tag: $tag"
git tag -d "$tag" # Delete tag locally
git push origin ":refs/tags/$tag"
done
fi
echo "Tag deletion process completed."
- name: Download all nightly artifacts
uses: actions/download-artifact@v4
with:
pattern: "*-artifact" # This will match ubuntu-latest-artifact, windows-latest-artifact, and macos-latest-artifact
path: build/ # Path to save the downloaded artifacts
merge-multiple: true
- name: Rename files from *-artifact to *-nightly
run: |
for file in $(find ./build -type f -name '*-artifact*'); do
new_file=$(echo "$file" | sed 's/-artifact/-nightly/g')
mv "$file" "$new_file"
done
- name: Release Nightly
uses: softprops/action-gh-release@v1
with:
name: Release Nightly Version
tag_name: ${{ steps.get_version.outputs.tag_name }}
files: build/*.*
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-unit-test:
uses: ./.github/workflows/linux-unit-test.yml
secrets: inherit