chore: Update git fetch command to force tags fetch #2
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: Build | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
jobs: | |
- { goos: darwin, goarch: arm64, output: arm64 } | |
- { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-compatible } | |
- { goos: darwin, goarch: amd64, goamd64: v3, output: amd64 } | |
- { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible, test: test } | |
- { goos: linux, goarch: amd64, goamd64: v3, output: amd64 } | |
- { goos: linux, goarch: arm64, output: arm64 } | |
- { goos: linux, goarch: arm, goarm: '5', output: armv5 } | |
- { goos: linux, goarch: arm, goarm: '6', output: armv6 } | |
- { goos: linux, goarch: arm, goarm: '7', output: armv7 } | |
- { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible } | |
- { goos: windows, goarch: amd64, goamd64: v3, output: amd64 } | |
- { goos: windows, goarch: arm, goarm: '7', output: armv7 } | |
- { goos: windows, goarch: arm64, output: arm64 } | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
if: ${{ matrix.jobs.goversion == '' }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
- name: Set variables | |
if: ${{github.ref_name=='' || github.ref_type=='tag'}} | |
run: echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV | |
shell: bash | |
- name: Set Time Variable | |
run: | | |
echo "BUILDTIME=$(date)" >> $GITHUB_ENV | |
echo "CGO_ENABLED=0" >> $GITHUB_ENV | |
echo "BUILDTAG=-extldflags --static" >> $GITHUB_ENV | |
- name: Build core | |
env: | |
GOOS: ${{matrix.jobs.goos}} | |
GOARCH: ${{matrix.jobs.goarch}} | |
GOAMD64: ${{matrix.jobs.goamd64}} | |
GOARM: ${{matrix.jobs.arm}} | |
GOMIPS: ${{matrix.jobs.mips}} | |
run: | | |
echo $CGO_ENABLED | |
go build -v -trimpath -ldflags "-w -s -buildid=" | |
if [ "${{matrix.jobs.goos}}" = "windows" ]; then | |
cp decodeGoogleOTP.exe decodeGoogleOTP-${{matrix.jobs.goos}}-${{matrix.jobs.output}}.exe | |
zip -r decodeGoogleOTP-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.zip decodeGoogleOTP-${{matrix.jobs.goos}}-${{matrix.jobs.output}}.exe | |
else | |
cp decodeGoogleOTP decodeGoogleOTP-${{matrix.jobs.goos}}-${{matrix.jobs.output}} | |
gzip -c decodeGoogleOTP-${{matrix.jobs.goos}}-${{matrix.jobs.output}} > decodeGoogleOTP-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}.gz | |
rm decodeGoogleOTP-${{matrix.jobs.goos}}-${{matrix.jobs.output}} | |
fi | |
- name: Save version | |
run: | | |
echo ${VERSION} > version.txt | |
shell: bash | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.jobs.goos }}-${{ matrix.jobs.output }} | |
path: | | |
decodeGoogleOTP*.gz | |
decodeGoogleOTP*.zip | |
version.txt | |
Upload-Release: | |
permissions: write-all | |
if: ${{ github.ref_type=='tag' }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get tags | |
run: | | |
echo "CURRENTVERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
git fetch --tags --force | |
echo "PREVERSION=$(git describe --tags --abbrev=0 HEAD^)" >> $GITHUB_ENV | |
- name: Generate release notes | |
run: | | |
cp ./.github/genReleaseNote.sh ./ | |
bash ./genReleaseNote.sh -v ${PREVERSION}...${CURRENTVERSION} | |
rm ./genReleaseNote.sh | |
- uses: actions/download-artifact@v4 | |
with: | |
path: bin/ | |
merge-multiple: true | |
- name: Display structure of downloaded files | |
run: ls -R | |
working-directory: bin | |
- name: Upload Release | |
uses: softprops/action-gh-release@v1 | |
if: ${{ success() }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
files: bin/* | |
generate_release_notes: true | |
body_path: release.md |