revert to static version #26
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: Build and Release | |
on: | |
push: | |
branches: | |
- "*" | |
tags: | |
- "v*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Get ref | |
id: branch | |
run: echo "ref=$(echo $GITHUB_REF | cut -d'/' -f3)" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.21.3 | |
- name: Build Binaries | |
id: build | |
env: | |
LINUX_AMD_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-linux-amd64.tar.gz | |
LINUX_ARM_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-linux-arm.tar.gz | |
WIN_AMD_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-win-amd64.zip | |
BIN_VERSION: ${{ steps.branch.outputs.ref }} | |
run: | | |
echo "Building Linux amd64 binary" | |
GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.Version=$BIN_VERSION'" -o na | |
tar -czvf ${LINUX_AMD_ARCHIVE} na | |
rm -v na | |
echo "Building Linux ARM binary" | |
GOOS=linux GOARCH=arm go build -ldflags "-X 'main.Version=$BIN_VERSION'" -o na | |
tar -czvf ${LINUX_ARM_ARCHIVE} na | |
rm -v na | |
echo "Building Windows amd64 binary" | |
GOOS=windows GOARCH=amd64 go build -ldflags "-X 'main.Version=$BIN_VERSION'" -o na.exe | |
zip ${WIN_AMD_ARCHIVE} na.exe | |
rm -v na.exe | |
ls -lah | |
- name: Upload binaries to artifacts | |
if: contains(github.ref, 'refs/tags/v') | |
uses: actions/upload-artifact@v2 | |
env: | |
LINUX_AMD_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-linux-amd64.tar.gz | |
LINUX_ARM_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-linux-arm.tar.gz | |
WIN_AMD_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-win-amd64.zip | |
with: | |
name: binaries | |
path: | | |
${{ env.LINUX_AMD_ARCHIVE }} | |
${{ env.LINUX_ARM_ARCHIVE }} | |
${{ env.WIN_AMD_ARCHIVE }} | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.event.ref, 'refs/tags/v') | |
permissions: write-all | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Get ref | |
id: branch | |
run: echo "ref=$(echo $GITHUB_REF | cut -d'/' -f3)" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Download binaries from artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: binaries | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "${{ steps.branch.outputs.ref }}" | |
release_name: "Sodium ${{ steps.branch.outputs.ref }}" | |
draft: false | |
prerelease: false | |
- name: Upload Linux amd64 Archive | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
LINUX_AMD_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-linux-amd64.tar.gz | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ env.LINUX_AMD_ARCHIVE }} | |
asset_name: ${{ env.LINUX_AMD_ARCHIVE }} | |
asset_content_type: application/octet-stream | |
- name: Upload Linux ARM Archive | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
LINUX_ARM_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-linux-arm.tar.gz | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ env.LINUX_ARM_ARCHIVE }} | |
asset_name: ${{ env.LINUX_ARM_ARCHIVE }} | |
asset_content_type: application/octet-stream | |
- name: Upload Windows amd64 Archive | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WIN_AMD_ARCHIVE: sodium-${{ steps.branch.outputs.ref }}-win-amd64.zip | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ env.WIN_AMD_ARCHIVE }} | |
asset_name: ${{ env.WIN_AMD_ARCHIVE }} | |
asset_content_type: application/octet-stream |