1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
github: l3uddz
|
||||
134
.github/workflows/build.yml
vendored
Normal file
134
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- edited
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# dependencies
|
||||
- name: dependencies
|
||||
run: |
|
||||
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sudo sh -s -- -b /usr/local/bin
|
||||
|
||||
# checkout
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# setup go
|
||||
- name: go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.15
|
||||
- run: go version
|
||||
- run: go env
|
||||
|
||||
# cache
|
||||
- name: cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
# vendor
|
||||
- name: vendor
|
||||
run: |
|
||||
make vendor
|
||||
|
||||
# build
|
||||
- name: build
|
||||
if: startsWith(github.ref, 'refs/tags/') == false
|
||||
run: |
|
||||
make snapshot
|
||||
|
||||
# get tag name
|
||||
- name: tag_name
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: little-core-labs/get-git-tag@v3.0.2
|
||||
with:
|
||||
tagRegex: "v?(.+)"
|
||||
|
||||
# publish
|
||||
- name: publish
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_REF: ${{ github.ref }}
|
||||
run: |
|
||||
make publish
|
||||
|
||||
# artifacts
|
||||
- name: artifact_linux
|
||||
uses: actions/upload-artifact@v2-preview
|
||||
with:
|
||||
name: build_linux
|
||||
path: dist/*linux*
|
||||
|
||||
- name: artifact_darwin
|
||||
uses: actions/upload-artifact@v2-preview
|
||||
with:
|
||||
name: build_darwin
|
||||
path: dist/*darwin*
|
||||
|
||||
- name: artifact_windows
|
||||
uses: actions/upload-artifact@v2-preview
|
||||
with:
|
||||
name: build_windows
|
||||
path: dist/*windows*
|
||||
|
||||
# docker build (latest & tag)
|
||||
- name: docker - build latest
|
||||
if: startsWith(github.ref, 'refs/tags/') == true
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry: docker.pkg.github.com
|
||||
repository: l3uddz/nabarr/nabarr
|
||||
dockerfile: docker/Dockerfile
|
||||
tags: latest
|
||||
tag_with_ref: true
|
||||
tag_with_sha: true
|
||||
always_pull: true
|
||||
|
||||
# docker build (master)
|
||||
- name: docker - build master
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry: docker.pkg.github.com
|
||||
repository: l3uddz/nabarr/nabarr
|
||||
dockerfile: docker/Dockerfile
|
||||
tags: master
|
||||
tag_with_sha: true
|
||||
always_pull: true
|
||||
|
||||
# docker build (branch)
|
||||
- name: docker - build other
|
||||
if: startsWith(github.ref, 'refs/heads/master') == false
|
||||
uses: docker/build-push-action@v1
|
||||
with:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
registry: docker.pkg.github.com
|
||||
repository: l3uddz/nabarr/nabarr
|
||||
dockerfile: docker/Dockerfile
|
||||
tag_with_ref: true
|
||||
tag_with_sha: false
|
||||
always_pull: true
|
||||
54
.github/workflows/cleanup.yml
vendored
Normal file
54
.github/workflows/cleanup.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Docker Cleanup
|
||||
|
||||
on: delete
|
||||
|
||||
jobs:
|
||||
cleanup_branch:
|
||||
if: startsWith(github.event.ref_type, 'branch') == true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Sanitize branch docker tag
|
||||
uses: frabert/replace-string-action@master
|
||||
id: dockertag
|
||||
with:
|
||||
pattern: '[:\.\/]+'
|
||||
string: "${{ github.event.ref }}"
|
||||
replace-with: '-'
|
||||
flags: 'g'
|
||||
|
||||
- name: query for package version id
|
||||
uses: octokit/graphql-action@v2.x
|
||||
id: query_package_version
|
||||
with:
|
||||
query: |
|
||||
query package($owner:String!,$repo:String!,$tag:String!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
packages(names:[$repo], first:1) {
|
||||
edges {
|
||||
node {
|
||||
id,
|
||||
name,
|
||||
version(version: $tag) {
|
||||
id, version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
owner: ${{ github.event.repository.owner.name }}
|
||||
repo: ${{ github.event.repository.name }}
|
||||
tag: ${{ steps.dockertag.outputs.replaced }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: parse package version id
|
||||
id: package_version
|
||||
run: echo "VERSION_ID=$(echo $json | jq -r $jsonpath)" >> $GITHUB_ENV
|
||||
env:
|
||||
json: ${{ steps.query_package_version.outputs.data }}
|
||||
jsonpath: ".repository.packages.edges[].node.version.id"
|
||||
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
package-version-ids: '${{ env.VERSION_ID }}'
|
||||
Reference in New Issue
Block a user