Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
Ankiaddon workflow attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
arsic authored and arsic committed Aug 14, 2023
1 parent 2e4f1d3 commit 3e15374
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash

# clean up
find . -regex '^.*\(__pycache__\|\.py[co]\)$' -delete

# make ankiaddon
zip -r ankicord.ankiaddon \
__init__.py \
config.json \
Expand Down

0 comments on commit 3e15374

Please sign in to comment.