Skip to content

Commit

Permalink
Fix workflow (#9)
Browse files Browse the repository at this point in the history
* Update path of file

* Update release asset workflow from fork

* Update download path for artifacts in workflow

* Upload and download data

* Fix paths

* Updated upload assets strategy

* Upload new better version for release

* add version on event

* Add checkout

* update git fetch

* Update linux and macos ext

* FIx executable extensions

* Include macos with arm processors

* Fix wrong executable naming

* test for assets

* Upload files to assets

* Remove file upload from build process

* test new workflow

* Add token

* Fix path

* extension

* Fix path

* Fix path

* Add download links for binaries

* super test

* Put download link in the body of the release

* test

* Update artifacts fetching

* dsa

* Implement final release workflow
  • Loading branch information
keybraker authored Feb 24, 2024
1 parent c419621 commit 3e94c08
Showing 1 changed file with 60 additions and 28 deletions.
88 changes: 60 additions & 28 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows]
goarch: [amd64]
include:
- OS: linux
ARCH: amd64
EXT: "bin"
- OS: windows
ARCH: amd64
EXT: "exe"
- OS: darwin
ARCH: amd64
EXT: "app"
- OS: darwin
ARCH: arm64
EXT: "app"
steps:
- uses: actions/checkout@v4

Expand All @@ -22,52 +33,73 @@ jobs:

- name: Build
run: |
env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -v -o mediarizer2-${{ matrix.goos }}-${{ matrix.goarch }} ./app
GOOS=${{ matrix.OS }} GOARCH=${{ matrix.ARCH }}
go build -v -o mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}.${{ matrix.EXT }} ./app
env:
GOOS: ${{ matrix.OS }}
GOARCH: ${{ matrix.ARCH }}
EXT: ${{ matrix.EXT }}

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: mediarizer2-${{ matrix.goos }}-${{ matrix.goarch }}
path: mediarizer2-${{ matrix.goos }}-${{ matrix.goarch }}
name: mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}.${{ matrix.EXT }}
path: mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}.${{ matrix.EXT }}

release:
needs: build
runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main'
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Fetch Tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Get commits since last tag
id: get_commits
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 --always)
if [ -z "$LATEST_TAG" ] || [[ "$LATEST_TAG" == *"$GITHUB_SHA"* ]]; then
LATEST_TAG=$(git rev-list --max-parents=0 HEAD)
fi
COMMIT_MESSAGES=$(git log $LATEST_TAG..HEAD --pretty=format:"%h - %s")
echo "::set-output name=commits::$COMMIT_MESSAGES"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: Release ${{ github.run_number }}
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Release ${{ github.run_number }}
- continuous deployment
- Commits included:
${{ steps.get_commits.outputs.commits }}
- Binaries:
(Download page)[https://github.com/keybraker/mediarizer-2/actions/runs/${{ github.run_id }}#artifacts]
draft: false
prerelease: false

- name: Upload Release Asset Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mediarizer2-linux-amd64
asset_name: mediarizer2-linux-amd64
asset_content_type: application/octet-stream
path: ./

- name: Upload Release Asset Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mediarizer2-windows-amd64
asset_name: mediarizer2-windows-amd64
asset_content_type: application/octet-stream
- name: Upload Release Assets
run: |
for file in mediarizer2-*; do
echo "Uploading $file"
asset_path="$file"
asset_name=$(basename $file)
echo "Asset Name: $asset_name"
curl \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$asset_path" \
"${{ steps.create_release.outputs.upload_url }}?name=$(urlencode $asset_name)"
done

0 comments on commit 3e94c08

Please sign in to comment.