1010 paths-ignore :
1111 - ' README.md'
1212 release :
13- types : [created]
13+ types : [published]
14+ workflow_dispatch :
15+
16+ concurrency :
17+ group : ci-${{ startsWith(github.ref, 'refs/pull') && github.ref || 'publish' }}
1418
1519jobs :
1620 build :
1721 runs-on : ubuntu-latest
18- container : devkitpro/devkitarm
22+ container : devkitpro/devkitarm:20241104
1923 name : Build with Docker using devkitARM
2024 outputs :
2125 commit_tag : ${{ steps.build.outputs.commit_tag }}
2630 commit_message : ${{ steps.build.outputs.commit_message }}
2731 steps :
2832 - name : Checkout repo
29- uses : actions/checkout@v1
33+ uses : actions/checkout@v4
3034 with :
3135 submodules : recursive
36+ fetch-depth : 0
37+ - name : Setup environment
38+ run : git config --global safe.directory '*'
3239 - name : Install tools
3340 run : |
3441 sudo apt-get update
@@ -43,43 +50,60 @@ jobs:
4350 mkdir -p ~/artifacts
4451 cp Relaunch.7z ~/artifacts
4552
46- echo ::set-output name=commit_tag::$(git describe --abbrev=0 --tags)
53+ echo ::set-output name=commit_tag::$(git describe --abbrev=0 --tags --exclude git )
4754 echo ::set-output name=commit_hash::$(git log --format=%h -1)
4855
4956 # Webhook info
50- echo ::set-output name=author_name::$(git log -1 " $GITHUB_SHA" --pretty=" %aN")
51- echo ::set-output name=committer_name::$(git log -1 " $GITHUB_SHA" --pretty=" %cN")
52- echo ::set-output name=commit_subject::$(git log -1 " $GITHUB_SHA" --pretty="%s")
53- echo ::set-output name=commit_message::$(git log -1 " $GITHUB_SHA" --pretty="%b")
57+ echo " ::set-output name=author_name::$(git log -1 $GITHUB_SHA --pretty=%aN)"
58+ echo " ::set-output name=committer_name::$(git log -1 $GITHUB_SHA --pretty=%cN)"
59+ echo " ::set-output name=commit_subject::$(git log -1 $GITHUB_SHA --pretty=%s)"
60+ echo " ::set-output name=commit_message::$(git log -1 $GITHUB_SHA --pretty=%b)"
5461 - name : Publish build to GH Actions
55- uses : actions/upload-artifact@v2
62+ uses : actions/upload-artifact@v4
5663 with :
5764 path : ~/artifacts/*
5865 name : build
5966
6067 # Only run this for non-PR jobs.
6168 publish_build :
6269 runs-on : ubuntu-latest
63- name : Publish build to Universal-Team/extras
70+ name : Publish build
6471 if : ${{ success() && !startsWith(github.ref, 'refs/pull') }}
6572 needs : build
6673 env :
6774 COMMIT_TAG : ${{ needs.build.outputs.commit_tag }}
6875 COMMIT_HASH : ${{ needs.build.outputs.commit_hash }}
6976 AUTHOR_NAME : ${{ needs.build.outputs.author_name }}
77+ COMMIT_SUBJECT : ${{ needs.build.outputs.commit_subject }}
7078 COMMIT_MESSAGE : ${{ needs.build.outputs.commit_message }}
71- outputs :
72- current_date : ${{ steps.commit.outputs.current_date }}
7379 steps :
7480 - name : Download artifacts
75- uses : actions/download-artifact@v2
81+ uses : actions/download-artifact@v4
7682 with :
7783 name : build
7884 path : build
79- - name : Upload to ${{ github.repository }} release
85+ # This one always runs
86+ - name : Delete the 'git' release
87+ run : |
88+ # Get the release ID for tag 'git'
89+ AUTH_HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
90+ CONTENT_TYPE="Content-Type: application/json"
91+ API_URL="https://api.github.com/repos/${{ github.repository }}/releases/tags/git"
92+
93+ RESPONSE=$(curl -H "$AUTH_HEADER" -H "$CONTENT_TYPE" "$API_URL")
94+ STATUS=$(echo $RESPONSE | jq -r .status)
95+ if [ "$STATUS" != "404" ]; then
96+ # If it exists, delete it
97+ ID=$(echo $RESPONSE | jq -r .id)
98+ API_URL="https://api.github.com/repos/${{ github.repository }}/releases/$ID"
99+ curl -XDELETE -H "$AUTH_HEADER" -H "$CONTENT_TYPE" "$API_URL"
100+ fi
101+
102+ # This one only runs for releases
103+ - name : Upload to ${{ github.ref_name }} release
80104 if : ${{ startsWith(github.ref, 'refs/tags') }}
81105 run : |
82- ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)
106+ ID=$(jq -r '.release.id' $GITHUB_EVENT_PATH)
83107
84108 for file in ${{ github.workspace }}/build/*; do
85109 AUTH_HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
@@ -89,62 +113,51 @@ jobs:
89113
90114 curl -XPOST -H "$AUTH_HEADER" -H "$CONTENT_LENGTH" -H "$CONTENT_TYPE" --upload-file "$file" "$UPLOAD_URL"
91115 done
92- - name : Commit and push to Universal-Team/extras
93- id : commit
116+
117+ # This one only runs if it's not a release run
118+ - name : Upload to 'git' release
119+ if : ${{ !startsWith(github.ref, 'refs/tags') }}
94120 run : |
95- CURRENT_DATE=$(date +"%Y%m%d-%H%M%S")
96- echo ::set-output name=current_date::$CURRENT_DATE
97-
98- git config --global user.email "flamekat54@aol.com"
99- git config --global user.name "TWLBot"
100- git clone --depth 1 https://${{ secrets.TWLBOT_TOKEN }}@github.com/Universal-Team/extras.git
101- mkdir -p extras/builds/Relaunch
102- cd extras/builds/Relaunch
103- cp ${{ github.workspace }}/build/* .
104- git stage .
105- git commit -m "Relaunch | $COMMIT_HASH"
106- git tag v$CURRENT_DATE
107- git push origin master v$CURRENT_DATE
108- - name : Release to Universal-Team/extras
109- run : |
110- AUTH_HEADER="Authorization: token ${{ secrets.TWLBOT_TOKEN }}"
121+ AUTH_HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
111122 CONTENT_TYPE="Content-Type: application/json"
112- API_URL="https://api.github.com/repos/Universal-Team/extras /releases"
113- RELEASE_INFO="{\"tag_name\": \"v${{ steps.commit.outputs.current_date }} \", \"name\": \"Relaunch | $COMMIT_HASH\", \"body\": \"$AUTHOR_NAME - $COMMIT_MESSAGE\", \"prerelease\": true}"
123+ API_URL="https://api.github.com/repos/${{ github.repository }} /releases"
124+ RELEASE_INFO="{\"tag_name\": \"git \", \"name\": \"Continuous Build - $COMMIT_HASH\", \"body\": \"$AUTHOR_NAME - $COMMIT_SUBJECT\n\n $COMMIT_MESSAGE\", \"prerelease\": true}"
114125
115126 RESPONSE=$(curl -XPOST -H "$AUTH_HEADER" -H "$CONTENT_TYPE" "$API_URL" -d "$RELEASE_INFO")
116-
117- ID=$(echo $RESPONSE | jq --raw-output '.id')
127+ ID=$(echo $RESPONSE | jq -r '.id')
118128
119129 for file in ${{ github.workspace }}/build/*; do
120- AUTH_HEADER="Authorization: token ${{ secrets.TWLBOT_TOKEN }}"
121130 CONTENT_LENGTH="Content-Length: $(stat -c%s $file)"
122131 CONTENT_TYPE="Content-Type: application/7z-x-compressed"
123- UPLOAD_URL="https://uploads.github.com/repos/Universal-Team/extras /releases/$ID/assets?name=$(basename $file)"
132+ UPLOAD_URL="https://uploads.github.com/repos/${{ github.repository }} /releases/$ID/assets?name=$(basename $file)"
124133
125134 curl -XPOST -H "$AUTH_HEADER" -H "$CONTENT_LENGTH" -H "$CONTENT_TYPE" --upload-file "$file" "$UPLOAD_URL"
126135 done
127136
128- send_webhook :
137+ send_success_webhook :
129138 runs-on : ubuntu-latest
130139 needs : [publish_build, build]
131- name : Send Discord webhook
132- if : ${{ !startsWith(github.ref, 'refs/pull') }}
140+ name : Send success webhook
141+ if : ${{ !startsWith(github.ref, 'refs/pull') && success() }}
133142 env :
134- CURRENT_DATE : ${{ needs.publish_build .outputs.current_date }}
143+ COMMIT_HASH : ${{ needs.build .outputs.commit_hash }}
135144 AUTHOR_NAME : ${{ needs.build.outputs.author_name }}
136145 COMMITTER_NAME : ${{ needs.build.outputs.committer_name }}
137146 COMMIT_SUBJECT : ${{ needs.build.outputs.commit_subject }}
138147 COMMIT_MESSAGE : ${{ needs.build.outputs.commit_message }}
139148 steps :
140149 - name : Send success webhook
141- if : ${{ success() }}
142150 run : |
143151 curl -o send.sh https://raw.githubusercontent.com/Universal-Team/discord-webhooks/master/send-ghactions.sh
144152 chmod +x send.sh
145153 ./send.sh success ${{ secrets.WEBHOOK_URL }}
154+ send_failure_webhook :
155+ runs-on : ubuntu-latest
156+ needs : [publish_build, build]
157+ name : Send failure webhook
158+ if : ${{ !startsWith(github.ref, 'refs/pull') && failure() }}
159+ steps :
146160 - name : Send failure webhook
147- if : ${{ failure() }}
148161 run : |
149162 curl -o send.sh https://raw.githubusercontent.com/Universal-Team/discord-webhooks/master/send-ghactions.sh
150163 chmod +x send.sh
0 commit comments