-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f11172a
commit f29ec09
Showing
1 changed file
with
131 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
name: Build / Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: golang:1 | ||
strategy: | ||
matrix: | ||
GOOS: ["linux", "darwin", "windows"] | ||
GOARCH: ["amd64", "arm64"] | ||
steps: | ||
- uses: Chia-Network/actions/git-mark-workspace-safe@main | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Binary | ||
env: | ||
GOOS: ${{ matrix.GOOS }} | ||
GOARCH: ${{ matrix.GOARCH }} | ||
run: make build | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: repo-content-updater-${{ matrix.GOOS }}-${{ matrix.GOARCH }} | ||
path: ${{ github.workspace }}/bin/repo-content-updater* | ||
|
||
installers: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
strategy: | ||
matrix: | ||
GOOS: ["linux"] | ||
GOARCH: ["amd64", "arm64"] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set Env | ||
uses: Chia-Network/actions/setjobenv@main | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install fpm | ||
run: sudo gem install fpm | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: repo-content-updater-${{ matrix.GOOS }}-${{ matrix.GOARCH }} | ||
path: artifacts | ||
|
||
- name: Generate .deb | ||
run: | | ||
chmod +x artifacts/repo-content-updater | ||
fpm \ | ||
--input-type dir \ | ||
--output-type deb \ | ||
--name repo-content-updater \ | ||
--architecture ${{ matrix.GOARCH }} \ | ||
--version "${{ env.RELEASE_TAG || github.sha }}" \ | ||
--url "https://github.com/Chia-Network/repo-content-updater" \ | ||
--maintainer "Chia Network Inc <hello@chia.net>" \ | ||
--description "Repo Content Updater" \ | ||
artifacts/repo-content-updater=/usr/local/bin/repo-content-updater | ||
mkdir -p installer-out | ||
mv *.deb installer-out/ | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: installer-repo-content-updater-${{ matrix.GOOS }}-${{ matrix.GOARCH }} | ||
path: ${{ github.workspace }}/installer-out/*.deb | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- installers | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set Env | ||
uses: Chia-Network/actions/setjobenv@main | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
path: artifacts | ||
|
||
- name: Show artifacts | ||
run: tree artifacts | ||
|
||
- name: Generate artifact zips | ||
if: env.RELEASE == 'true' | ||
run: | | ||
cd ${{ github.workspace }}/artifacts || exit 1 | ||
DIRS=$(find . -type d -name 'repo-content-updater*') | ||
while IFS= read -r dir; do | ||
echo "Creating zip for $dir..." | ||
zip -r $dir.zip $dir | ||
done <<< "$DIRS" | ||
- name: Upload Release Artifacts | ||
if: env.RELEASE == 'true' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
FILES=$(find ${{ github.workspace }}/artifacts -type f -name 'repo-content-updater*.zip') | ||
while IFS= read -r file; do | ||
gh release upload \ | ||
$RELEASE_TAG \ | ||
$file | ||
done <<< "$FILES" | ||
gh release upload \ | ||
$RELEASE_TAG \ | ||
artifacts/installer-repo-content-updater*/*.deb |