-
Notifications
You must be signed in to change notification settings - Fork 74
81 lines (75 loc) · 2.91 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
name: Release
on:
workflow_dispatch: ~
push:
branches: [ master ]
jobs:
# Create a Release
create_release:
name: 🚀 Create Release
runs-on: ubuntu-latest
outputs:
release_exists: ${{ steps.check_release.outputs.release_exists }}
release_id: ${{ steps.check_release.outputs.release_id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Check if release exists
id: check_release
run: |
release_name="${{ steps.date.outputs.date }}"
release_data=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases/tags/${release_name}")
if [ "$release_id" != "null" ]; then
echo "release_exists=true" >> $GITHUB_OUTPUT
echo "release_id=$(echo $release_data | jq -r '.id')" >> $GITHUB_OUTPUT
else
echo "release_exists=false" >> $GITHUB_OUTPUT
fi
- name: Delete Existing Release
if: steps.check_release.outputs.release_exists == 'true'
run: |
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.check_release.outputs.release_id }}
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ steps.date.outputs.date }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.date.outputs.date }}
release_name: Amendment ${{ steps.date.outputs.date }}
draft: false
prerelease: false
upload_pdf:
name: 🚀 Upload PDF Copy
needs: create_release # Depends on release being created for upload URL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install TexLive, TexLive formats-extra, Git, and Make
run: |
sudo apt-get update
sudo apt-get install -y texlive texlive-formats-extra git make
- name: 🔨 Build
run: |
make
- name: 🌥️⬆️ Upload Assets - New Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: Constitution.pdf
asset_path: ./constitution.pdf
asset_content_type: application/pdf