Skip to content

Commit

Permalink
feat: update releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
mtaku3 committed Jan 17, 2023
1 parent 2a44739 commit 2d44071
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 48 deletions.
106 changes: 81 additions & 25 deletions repofilter/filter/files/automuteus/.github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,99 @@ on:
- "*"

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create release
if: ${{ !env.ACT }}
shell: bash
run: gh release create $TAG --title $TAG
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}

releaser:
runs-on: windows-latest
runs-on: ubuntu-latest
needs: create-release
strategy:
matrix:
target:
- os: windows
arch: 386

- os: windows
arch: amd64

- os: windows
arch: arm

- os: windows
arch: arm64
env:
REPOSITORY_NAME: ${{ github.event.repository.name }}
TAG: ${{ github.ref_name }}
TARGETOS: ${{ matrix.target.os }}
TARGETARCH: ${{ matrix.target.arch }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install xxhash
if: ${{ !env.ACT }}
shell: bash
run: |
sudo apt-fast update
sudo apt-fast install -y xxhash
- name: Install xxhash (only on act)
if: ${{ env.ACT }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y xxhash
- name: Set up Go
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18

go-version: ^1.18.0
- name: Build
shell: pwsh
shell: bash
run: |
$TAG = git describe --tags "$(git rev-list --tags --max-count=1)"
$COMMIT = git rev-parse --short HEAD
go build -installsuffix 'static' -ldflags="-X main.version=$TAG -X main.commit=$COMMIT" -o ../build/automuteus.exe .
Copy-Item -Path .\locales\ -Destination ..\build\locales\ -Recurse
New-Item -Path ..\build\ -Name storage -ItemType directory
Copy-Item -Path .\storage\postgres.sql ..\build\storage\postgres.sql
export TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)") && \
export COMMIT=$(git rev-parse --short HEAD) && \
CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
go build -installsuffix 'static' \
-ldflags="-X main.version=${TAG} -X main.commit=${COMMIT}" \
-o ../build/automuteus.exe .
- name: Compress build files to zip
shell: pwsh
run: Compress-Archive -Path ../build/* -DestinationPath ../automuteus.zip

- name: Create hashes.txt
shell: pwsh
cp -r ./locales/ ../build/locales
mkdir ../build/storage
cp ./storage/postgres.sql ../build/storage/postgres.sql
- name: Compress to zip
shell: bash
run: |
Get-ChildItem ..\build\ -Recurse -File -Force -ea SilentlyContinue -ev errs | Get-FileHash -Algorithm SHA256 | Select-Object -Property Hash, @{Label="Path"; Expression={((Resolve-Path -Relative $_.Path) -replace '..\\build\\','') -replace '\\','/'}} | ForEach-Object { $_.Hash + " " + $_.Path } | Out-File -FilePath ..\hashes.txt
- name: Create release
id: create_release
shell: pwsh
run: |
gh release create $env:TAG ../automuteus.zip ../hashes.txt --title "$env:TAG"
pushd ../build/
zip -r ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.zip *
popd
- name: Calculate checksum
shell: bash
run: find ../build/ -type f -print0 | xargs -0 xxhsum -H3 -- | sed "s/XXH3 (\.\.\/build\/\(.\+\)) = \([a-z0-9]\+\)/\2 \1/" > ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.checksum.txt

- name: Upload assets to release
if: ${{ !env.ACT }}
shell: bash
run: gh release upload $TAG ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.zip ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.checksum.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
101 changes: 78 additions & 23 deletions repofilter/filter/files/galactus/.github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,95 @@ on:
- "*"

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create release
if: ${{ !env.ACT }}
shell: bash
run: gh release create $TAG --title $TAG
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}

releaser:
runs-on: windows-latest
runs-on: ubuntu-latest
needs: create-release
strategy:
matrix:
target:
- os: windows
arch: 386

- os: windows
arch: amd64

- os: windows
arch: arm

- os: windows
arch: arm64
env:
REPOSITORY_NAME: ${{ github.event.repository.name }}
TAG: ${{ github.ref_name }}
TARGETOS: ${{ matrix.target.os }}
TARGETARCH: ${{ matrix.target.arch }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install xxhash
if: ${{ !env.ACT }}
shell: bash
run: |
sudo apt-fast update
sudo apt-fast install -y xxhash
- name: Install xxhash (only on act)
if: ${{ env.ACT }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y xxhash
- name: Set up Go
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.18

go-version: ^1.18.0
- name: Build
shell: pwsh
run: |
$TAG = git describe --tags "$(git rev-list --tags --max-count=1)"
$COMMIT = git rev-parse --short HEAD
go build -installsuffix 'static' -ldflags="-X main.version=$TAG -X main.commit=$COMMIT" -o ../build/galactus.exe .
- name: Compress build files to zip
shell: pwsh
run: Compress-Archive -Path ../build/* -DestinationPath ../galactus.zip

- name: Create hashes.txt
shell: pwsh
shell: bash
run: |
Get-ChildItem ..\build\ -Recurse -File -Force -ea SilentlyContinue -ev errs | Get-FileHash -Algorithm SHA256 | Select-Object -Property Hash, @{Label="Path"; Expression={((Resolve-Path -Relative $_.Path) -replace '..\\build\\','') -replace '\\','/'}} | ForEach-Object { $_.Hash + " " + $_.Path } | Out-File -FilePath ..\hashes.txt
- name: Create release
id: create_release
shell: pwsh
export TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)") && \
export COMMIT=$(git rev-parse --short HEAD) && \
CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
go build -installsuffix 'static' \
-ldflags="-X main.version=${TAG} -X main.commit=${COMMIT}" \
-o ../build/galactus.exe .
- name: Compress to zip
shell: bash
run: |
gh release create $env:TAG ../galactus.zip ../hashes.txt --title "$env:TAG"
pushd ../build/
zip -r ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.zip *
popd
- name: Calculate checksum
shell: bash
run: find ../build/ -type f -print0 | xargs -0 xxhsum -H3 -- | sed "s/XXH3 (\.\.\/build\/\(.\+\)) = \([a-z0-9]\+\)/\2 \1/" > ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.checksum.txt

- name: Upload assets to release
if: ${{ !env.ACT }}
shell: bash
run: gh release upload $TAG ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.zip ../${REPOSITORY_NAME}.${TAG}.${TARGETOS}-${TARGETARCH}.checksum.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}

0 comments on commit 2d44071

Please sign in to comment.