replace deprecated set-output #4
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 | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: [1.21.x] | |
os: [linux, darwin, windows] | |
steps: | |
# Check out | |
- uses: actions/checkout@v4 | |
# Prepare build | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Extract project version | |
id: project_version | |
run: echo "version=$(grep 'const version =' colorexp.go | cut -d '"' -f 2)" >> $GITHUB_STATE | |
- name: Extract commit hash | |
id: git_commit | |
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Download dependencies | |
run: go mod tidy | |
# Build | |
- name: Build | |
run: | | |
env GOOS=${{ matrix.os }} GOARCH=amd64 go build -o colorexp-${{ matrix.os }}-amd64-${{ steps.project_version.outputs.version }}-${{ steps.git_commit.outputs.sha }} colorexp.go | |
- name: Upload artifact | |
if: github.event_name == 'push' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: colorexp-${{ matrix.os }}-amd64-${{ steps.project_version.outputs.version }}-${{ steps.git_commit.outputs.sha }} | |
path: colorexp-${{ matrix.os }}-amd64-${{ steps.project_version.outputs.version }}-${{ steps.git_commit.outputs.sha }} | |
# Create a GitHub release | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.version }} | |
release_name: Release ${{ env.version }} | |
draft: false | |
prerelease: false | |
# Upload release asset for each OS | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./colorexp-${{ matrix.os }}-amd64-${{ env.version }}-${{ env.sha }} | |
asset_name: colorexp-${{ matrix.os }}-amd64-${{ env.version }}-${{ env.sha }} | |
asset_content_type: application/octet-stream |