|
| 1 | +name: Create Release & Upload Assets |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + # Sequence of patterns matched against refs/tags |
| 6 | + tags: |
| 7 | + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Lint, Test, Build |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Install dependencies |
| 15 | + run: sudo apt update && sudo apt install -y libpcsclite-dev |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - name: Setup Go |
| 19 | + uses: actions/setup-go@v3 |
| 20 | + with: |
| 21 | + go-version: "1.18" |
| 22 | + - name: golangci-lint |
| 23 | + uses: golangci/golangci-lint-action@v2 |
| 24 | + with: |
| 25 | + version: latest |
| 26 | + - name: Test, Build |
| 27 | + id: lintTestBuild |
| 28 | + run: V=1 make ci |
| 29 | + |
| 30 | + create_release: |
| 31 | + name: Create Release |
| 32 | + needs: test |
| 33 | + runs-on: ubuntu-latest |
| 34 | + outputs: |
| 35 | + version: ${{ steps.extract-tag.outputs.VERSION }} |
| 36 | + vversion: ${{ steps.extract-tag.outputs.VVERSION }} |
| 37 | + is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }} |
| 38 | + steps: |
| 39 | + - name: Extract Tag Names |
| 40 | + id: extract-tag |
| 41 | + run: | |
| 42 | + VVERSION=${GITHUB_REF#refs/tags/} |
| 43 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 44 | + echo "::set-output name=VVERSION::${VVERSION}" |
| 45 | + echo "::set-output name=VERSION::${VERSION}" |
| 46 | + - name: Is Pre-release |
| 47 | + id: is_prerelease |
| 48 | + run: | |
| 49 | + set +e |
| 50 | + echo ${{ github.ref }} | grep "\-rc.*" |
| 51 | + OUT=$? |
| 52 | + if [ $OUT -eq 0 ]; then IS_PRERELEASE=true; else IS_PRERELEASE=false; fi |
| 53 | + echo "::set-output name=IS_PRERELEASE::${IS_PRERELEASE}" |
| 54 | + - name: Create Release |
| 55 | + id: create_release |
| 56 | + uses: actions/create-release@v1 |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + with: |
| 60 | + tag_name: ${{ github.ref }} |
| 61 | + release_name: Release ${{ github.ref }} |
| 62 | + draft: false |
| 63 | + prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }} |
| 64 | + |
| 65 | + goreleaser: |
| 66 | + name: Upload Assets to Github w/ goreleaser |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: create_release |
| 69 | + steps: |
| 70 | + - name: Install dependencies |
| 71 | + run: sudo apt update && sudo apt install -y libpcsclite-dev |
| 72 | + - name: Checkout |
| 73 | + uses: actions/checkout@v3 |
| 74 | + with: |
| 75 | + fetch-depth: 0 |
| 76 | + - name: Set up Go |
| 77 | + uses: actions/setup-go@v3 |
| 78 | + with: |
| 79 | + go-version: 1.18 |
| 80 | + - name: release dry run |
| 81 | + run: make release-dry-run |
| 82 | + - name: setup release environment |
| 83 | + run: |- |
| 84 | + echo 'GITHUB_TOKEN=${{secrets.GORELEASER_ACCESS_TOKEN}}' > .release-env |
| 85 | + - name: release publish |
| 86 | + run: make release |
0 commit comments