Skip to content

Commit

Permalink
Automatically create releases on new tags
Browse files Browse the repository at this point in the history
Fixed ci workflow trying to upload binary multiple times

Signed-off-by: Petu Eusebiu <[email protected]>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Apr 4, 2022
1 parent 387d844 commit 0cbbe74
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 39 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Reusable stacker build
on:
workflow_call:
inputs:
go-version:
required: true
type: string
description: 'Stringified JSON object listing go versions'
privilege-level:
required: true
type: string
description: 'Stringified JSON object listing stacker privilege-level'
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
go-version: ${{fromJson(inputs.go-version)}}
privilege-level: ${{fromJson(inputs.privilege-level)}}
name: "golang ${{ matrix.go-version }} privilege ${{ matrix.privilege-level }}"
steps:
- uses: actions/checkout@v2
- name: Set up golang ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install -yy lxc-utils lxc-dev libacl1-dev jq libcap-dev libseccomp-dev libpam-dev bats parallel libzstd-dev
GO111MODULE=off go get github.com/opencontainers/umoci/cmd/umoci
sudo cp ~/go/bin/umoci /usr/bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
sudo apt-get install -yy autoconf automake make autogen autoconf libtool binutils git squashfs-tools libcryptsetup-dev libdevmapper-dev cryptsetup-bin
(cd /tmp && git clone https://github.com/AgentD/squashfs-tools-ng && cd squashfs-tools-ng && ./autogen.sh && ./configure --prefix=/usr && make -j2 && sudo make -j2 install && sudo ldconfig -v)
(cd /tmp && git clone https://github.com/anuvu/squashfs && cd squashfs && make && sudo cp squashtool/squashtool /usr/bin)
- run: |
make check PRIVILEGE_LEVEL=${{ matrix.privilege-level }}
- uses: actions/cache@v2
id: restore-build
with:
path: stacker
key: ${{ github.sha }}
53 changes: 14 additions & 39 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,19 @@
name: ci

on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0' # weekly
release:
types:
- published
push:
pull_request:
schedule:
- cron: "0 0 * * 0" # weekly
release:
types:
- published

jobs:
build:
runs-on: ubuntu-20.04
name: "golang ${{ matrix.go-version }} privilege ${{ matrix.privilege-level }}"
strategy:
matrix:
go-version: [1.17.x, 1.18.x]
privilege-level: [priv, unpriv]
steps:
- uses: actions/checkout@v2
- name: Set up golang ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install -yy lxc-utils lxc-dev libacl1-dev jq libcap-dev libseccomp-dev libpam-dev bats parallel libzstd-dev
GO111MODULE=off go get github.com/opencontainers/umoci/cmd/umoci
sudo cp ~/go/bin/umoci /usr/bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
sudo apt-get install -yy autoconf automake make autogen autoconf libtool binutils git squashfs-tools libcryptsetup-dev libdevmapper-dev cryptsetup-bin
(cd /tmp && git clone https://github.com/AgentD/squashfs-tools-ng && cd squashfs-tools-ng && ./autogen.sh && ./configure --prefix=/usr && make -j2 && sudo make -j2 install && sudo ldconfig -v)
(cd /tmp && git clone https://github.com/anuvu/squashfs && cd squashfs && make && sudo cp squashtool/squashtool /usr/bin)
- run: |
make check PRIVILEGE_LEVEL=${{ matrix.privilege-level }}
- if: github.event_name == 'release' && github.event.action == 'published'
name: Publish artifacts on releases
uses: Roang-zero1/github-upload-release-artifacts-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: stacker
ci:
uses: ./.github/workflows/build.yaml
with:
go-version: >-
["1.17.x", "1.18.x"]
privilege-level: >-
["unpriv", "priv"]
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "tagged-release"

on:
push:
tags:
- "v*"

jobs:
ci:
uses: ./.github/workflows/build.yaml
with:
go-version: >-
["1.17.x"]
privilege-level: >-
["priv"]
release:
name: "Tagged Release"
runs-on: ubuntu-20.04
steps:
- uses: actions/cache@v2
id: restore-build
with:
path: stacker
key: ${{ github.sha }}
- uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: stacker




0 comments on commit 0cbbe74

Please sign in to comment.