Go #212
Workflow file for this run
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: Go | |
on: | |
create: | |
tags: | |
- v4* | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 1 | |
- name: Set up Env | |
run: echo "version=${GITHUB_REF:11}" >> $GITHUB_ENV | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.20.7 | |
- name: Cache Go modules | |
uses: actions/cache@v1 | |
with: | |
path: ~/go/pkg/mod | |
key: runner.os−go−{ { hashFiles('**/go.sum') } } | |
restore-keys: ${{ runner.os }}-go- | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v2 | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
with: | |
version: v1.8.3 | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout m7s-import | |
uses: actions/checkout@v3 | |
with: | |
repository: langhuihui/m7s-import | |
path: m7s-import | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 | |
- name: Add bin to m7s-import | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
run: | | |
cd m7s-import | |
mkdir -p apps/m7s-website/src/public/bin | |
cp ../dist/m7s_${{ env.version }}_windows_amd64.tar.gz apps/m7s-website/src/public/bin/m7s_windows_amd64.tar.gz | |
cp ../dist/m7s_${{ env.version }}_darwin_amd64.tar.gz apps/m7s-website/src/public/bin/m7s_darwin_amd64.tar.gz | |
cp ../dist/m7s_${{ env.version }}_darwin_arm64.tar.gz apps/m7s-website/src/public/bin/m7s_darwin_arm64.tar.gz | |
cp ../dist/m7s_${{ env.version }}_linux_amd64.tar.gz apps/m7s-website/src/public/bin/m7s_linux_amd64.tar.gz | |
cp ../dist/m7s_${{ env.version }}_linux_arm64.tar.gz apps/m7s-website/src/public/bin/m7s_linux_arm64.tar.gz | |
releaseinfo=`curl -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest` | |
body=`echo $releaseinfo | jq ".body" | sed -e 's/^"//' -e 's/"$//'` | |
name=`echo $releaseinfo | jq ".name" | sed -e 's/^"//' -e 's/"$//'` | |
touch apps/m7s-website/src/release.txt | |
echo -e "# $name\n$body" | cat - apps/m7s-website/src/release.txt > temp && mv temp apps/m7s-website/src/release.txt | |
sed "/## Changelog/d" -i apps/m7s-website/src/release.txt | |
git config --global user.name 'langhuihui' | |
git config --global user.email '[email protected]' | |
git add -A | |
git commit -m '[automated commit] add bin & GitHub workflow' | |
- name: push to m7s-import | |
uses: ad-m/github-push-action@master | |
if: success() && startsWith(github.ref, 'refs/tags/') | |
with: | |
github_token: ${{ secrets.TOKEN }} | |
directory: m7s-import | |
repository: langhuihui/m7s-import |