Skip to content

Commit b822ea7

Browse files
committed
GHAでのビルドに対応
1 parent 74bb77e commit b822ea7

6 files changed

Lines changed: 212 additions & 148 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and release for official
2+
3+
on:
4+
push:
5+
tags:
6+
- "*.*.*"
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/testAndBuild.yml
11+
with:
12+
official_release: true
13+
14+
deploy:
15+
needs: build
16+
runs-on: windows-latest
17+
18+
steps:
19+
- name: Download artifact
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: ${{ github.event.repository.name }}
23+
path: ./
24+
25+
- name: Deploy to GitHub
26+
uses: softprops/action-gh-release@v1
27+
with:
28+
body: ${{ github.event.repository.name }} official release
29+
draft: true
30+
files: |
31+
./${{ github.event.repository.name }}-*.zip
32+
./${{ github.event.repository.name }}-*.json
33+
34+
error_notify:
35+
runs-on: ubuntu-latest
36+
needs: deploy
37+
if: ${{ failure() }}
38+
steps:
39+
- name: Send GitHub Action trigger data to Slack workflow
40+
uses: slackapi/slack-github-action@v1
41+
with:
42+
payload: |
43+
{
44+
"text": "Github actions build failed! <${{ github.server_url }}/${{ github.repository }}|${{ github.event.repository.name }}>のofficial releaseビルドが失敗しました。\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|対象のrun>お確認し、対応着手時・完了後は、本チャンネルにて経緯を報告ください。"
45+
}
46+
env:
47+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK_URL }}
48+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
49+

‎.github/workflows/snapshot.yml‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and release for snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/testAndBuild.yml
11+
12+
deploy:
13+
needs: build
14+
runs-on: windows-latest
15+
16+
steps:
17+
- name: Download artifact
18+
uses: actions/download-artifact@v4
19+
with:
20+
name: ${{ github.event.repository.name }}
21+
path: ./
22+
23+
- name: Re-create the tag
24+
uses: actions/github-script@v7
25+
with:
26+
script: |
27+
const { owner, repo } = context.repo
28+
const tagName = repo + "-latestcommit"
29+
try {
30+
// Fetch the release by its tag
31+
const { data: release } = await github.rest.repos.getReleaseByTag({ owner, repo, tag: tagName })
32+
// Delete the release if exists
33+
await github.rest.repos.deleteRelease({ owner, repo, release_id: release.id })
34+
console.log("deleted release");
35+
} catch(err) {
36+
if(err.status !== 404){
37+
throw err;
38+
}
39+
console.log('No release found for deletion');
40+
}
41+
try {
42+
await github.rest.git.deleteRef({owner, repo, ref: "tags/" + tagName})
43+
console.log("deleted tag");
44+
} catch(err) {
45+
console.log('Failed to delete tag'+err.message);
46+
}
47+
try {
48+
await github.rest.git.createRef({owner, repo, ref: "refs/tags/" + tagName, sha: context.sha})
49+
console.log("created tag");
50+
} catch(err) {
51+
console.log('Failed to create tag'+err.message);
52+
}
53+
54+
- name: Deploy to GitHub
55+
uses: softprops/action-gh-release@v1
56+
with:
57+
name: Snapshot
58+
tag_name: ${{ github.event.repository.name }}-latestcommit
59+
body: Automatic build from master branch
60+
files: |
61+
./${{ github.event.repository.name }}-*.zip
62+
./${{ github.event.repository.name }}-*.json
63+
64+
- name: register snapshot to actlab site
65+
run: |
66+
curl "https://actlab.org/api/addAlphaVersion?repo_name=${{ github.repository }}&commit_hash=${{ github.sha }}&version=${{ needs.build.outputs.build_version }}&password=${{ secrets.SCRIPT_PASSWORD }}"
67+
68+
error_notify:
69+
runs-on: ubuntu-latest
70+
needs: deploy
71+
if: ${{ failure() }}
72+
steps:
73+
- name: Send GitHub Action trigger data to Slack workflow
74+
uses: slackapi/slack-github-action@v1
75+
with:
76+
payload: |
77+
{
78+
"text": "Github actions build failed! <${{ github.server_url }}/${{ github.repository }}|${{ github.event.repository.name }}>のビルドが失敗しました。\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|対象のrun>お確認し、対応着手時・完了後は、本チャンネルにて経緯を報告ください。"
79+
}
80+
env:
81+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK_URL }}
82+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
83+

‎.github/workflows/testAndBuild.yml‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Test and build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
official_release:
7+
description: Whether this is an official release
8+
default: false
9+
type: boolean
10+
outputs:
11+
build_version:
12+
description: Version of the built package
13+
value: ${{ jobs.build.outputs.build_version }}
14+
15+
jobs:
16+
build:
17+
runs-on: windows-latest
18+
outputs:
19+
build_version: ${{ steps.output_version.outputs.version }}
20+
21+
steps:
22+
- name: Check out repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
architecture: x86
29+
python-version: 3.12
30+
cache: pip
31+
32+
- name: Install requirements
33+
run: |
34+
python -m pip install -r requirements.txt
35+
36+
- name: Set tag name if This is an official release
37+
run: echo "TAG_NAME=$($env:GITHUB_REF.Replace('refs/tags/', ''))" >> $env:GITHUB_ENV
38+
if: ${{ inputs.official_release }}
39+
40+
- name: Build
41+
run: |
42+
python tools\build.py
43+
env:
44+
COMMIT_TIMESTAMP: ${{ github.event.head_commit.timestamp}}
45+
46+
- name: output version
47+
id: output_version
48+
shell: python
49+
run: |
50+
import os, sys
51+
sys.path.append(os.getcwd())
52+
import constants
53+
with open(os.environ["GITHUB_OUTPUT"], mode = "a") as f:
54+
f.write("version="+constants.APP_VERSION)
55+
56+
- name: Archive production artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: ${{ github.event.repository.name }}
60+
path: |
61+
./${{ github.event.repository.name }}-*.zip
62+
./${{ github.event.repository.name }}-*.json
63+

‎appveyor-release.yml‎

Lines changed: 0 additions & 53 deletions
This file was deleted.

‎appveyor.yml‎

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)