Added permissions content: write #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Baobud | |
on: | |
push: | |
tags: | |
- "v*" | |
branches: | |
- main | |
pull_request: | |
permissions: | |
contents: write | |
jobs: | |
build-and-test: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
platform: linux | |
arch: amd64 | |
bao_url: https://github.com/openbao/openbao/releases/download/v2.0.1/bao_2.0.1_linux_amd64.deb | |
# - os: ubuntu-latest | |
# platform: linux | |
# arch: arm64 | |
# bao_url: https://github.com/openbao/openbao/releases/download/v2.0.1/bao_2.0.1_linux_arm64.deb | |
# - os: macos-latest | |
# platform: darwin | |
# arch: arm64 | |
# bao_url: https://github.com/openbao/openbao/releases/download/v2.0.1/bao_2.0.1_Darwin_arm64.tar.gz | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
- name: Install OpenBao | |
run: | | |
if [[ "${{ matrix.bao_url }}" == *.deb ]]; then | |
curl -Lo openbao.deb ${{ matrix.bao_url }} | |
sudo dpkg -i openbao.deb | |
rm openbao.deb | |
else | |
curl -Lo openbao.tar.gz ${{ matrix.bao_url }} | |
tar xzf openbao.tar.gz | |
sudo mv bao /usr/local/bin/ | |
rm openbao.tar.gz | |
fi | |
- name: Run tests | |
run: make test | |
- name: Build | |
env: | |
GOARCH: ${{ matrix.arch }} | |
GOOS: ${{ matrix.platform }} | |
run: | | |
mkdir -p bin | |
go build -ldflags="-s -w" -o bin/baobud-${{ matrix.platform }}-${{ matrix.arch }} cmd/main.go | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: baobud-${{ matrix.platform }}-${{ matrix.arch }} | |
path: bin/baobud-${{ matrix.platform }}-${{ matrix.arch }} | |
retention-days: 1 | |
release: | |
needs: build-and-test | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Create bin directory | |
run: | | |
mkdir -p bin | |
ls -R | |
- name: Prepare artifacts for release | |
run: | | |
chmod +x artifacts/*/baobud-* | |
for dir in artifacts/*/; do | |
mv "$dir"/* bin/ | |
done | |
- name: Generate checksums | |
run: | | |
cd bin | |
sha256sum baobud-* > checksums.txt | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
bin/baobud-linux-amd64 | |
bin/checksums.txt | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |