This repository has been archived by the owner on Sep 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
103 lines (91 loc) · 2.71 KB
/
build.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
---
name: build
on:
push:
branches:
master
pull_request:
jobs:
build:
name: Build ankiaddon
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: zip and rename
shell: bash
run: ./build.sh
- name: upload
uses: actions/[email protected]
with:
name: ankicord.ankiaddon
path: ./ankicord.ankiaddon
create-release:
name: create release
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: set env vars for release
run: |
echo "tag_name=nightly-build" >> $GITHUB_ENV
echo "release_name=Nightly Release" >> $GITHUB_ENV
- name: delete previous nightly release and tag
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const { owner, repo } = context.repo;
const release = await github.rest.repos.getReleaseByTag({
owner: owner,
repo: repo,
tag: process.env.tag_name
})
await github.rest.repos.deleteRelease({
owner,
repo,
release_id: release.data.id
})
await github.rest.git.deleteRef({
owner,
repo,
ref: `tags/${process.env.tag_name}`
})
} catch (err) {
core.error(`error deleting release or tag: ${err}`)
}
- name: create new nightly tag and release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.tag_name }}
release_name: ${{ env.release_name }}
draft: false
prerelease: true
upload-release-assets:
name: upload release
needs: [config, create-release]
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: download artifact
uses: actions/[email protected]
with:
name: ankicord.ankiaddon
path: ./ubuntu-latest
- name: upload release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./ubuntu-latest/ankicord.ankiaddon
asset_name: ankicord.ankiaddon
asset_content_type: application/zip