Skip to content

Commit

Permalink
ci: Use action to make releases with artifacts (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjliggett committed Feb 6, 2022
1 parent ed8bcb1 commit 21b6691
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 26 deletions.
142 changes: 116 additions & 26 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,11 @@ jobs:
- run: rm resource.syso
- run: env GOOS=windows GOARCH=arm go build -a -v -o jjversion-${{ env.VERSION }}-windows-arm/jjversion.exe -ldflags "-X main.appVersion=${{ env.VERSION }}"

# Prepare directories - copy README and docs (attributions)
- run: cp README.md jjversion-${{ env.VERSION }}-linux-x64/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-x64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-linux-arm64/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-arm64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-linux-arm/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-arm/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-linux-386/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-386/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-darwin-amd64/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-darwin-amd64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-windows-x64/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-windows-x64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-windows-386/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-windows-386/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-windows-arm/jjversion-README.md
- run: cp -R docs jjversion-${{ env.VERSION }}-windows-arm/jjversion-docs

- run: ls -R
- name: Upload jjversion docs
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
with:
name: jjversion-${{ env.VERSION }}-docs
path: docs/

- name: Upload jjversion linux x64
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
Expand Down Expand Up @@ -198,12 +184,6 @@ jobs:
name: jjversion-${{ env.VERSION }}-windows-arm
path: jjversion-${{ env.VERSION }}-windows-arm/

- name: Upload jjversion.exe
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
with:
name: jjversion.exe
path: jjversion-${{ env.VERSION }}-windows-x64/jjversion.exe

publish:
runs-on: ubuntu-latest
needs:
Expand All @@ -222,6 +202,7 @@ jobs:
- test-docker-commit-tags-lightweight-highest
- test-commit-incrementing-custom-versioning-settings
- test-commit-incrementing-no-settings
- build-cross-compilation
steps:
- uses: actions/checkout@230611dbd0eb52da1e1f4f7bc8bb0c3a339fc8b7
with:
Expand All @@ -230,12 +211,100 @@ jobs:
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion

- run: chmod +x jjversion
- run: sudo mv jjversion /usr/local/bin
- run: jjversion
- run: echo "VERSION=$(jjversion | jq --raw-output '.MajorMinorPatch')" >> $GITHUB_ENV
- run: git reset --hard HEAD~1

- run: git reset --soft HEAD~1
- run: echo "PREVIOUS_COMMIT_VERSION=$(jjversion | jq --raw-output '.MajorMinorPatch')" >> $GITHUB_ENV

- name: Download jjversion linux x64
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-linux-x64
path: jjversion-${{ env.VERSION }}-linux-x64/
- name: Download jjversion linux arm64
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-linux-arm64
path: jjversion-${{ env.VERSION }}-linux-arm64/
- name: Download jjversion linux arm
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-linux-arm
path: jjversion-${{ env.VERSION }}-linux-arm/
- name: Download jjversion linux 386
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-linux-386
path: jjversion-${{ env.VERSION }}-linux-386/
- name: Download jjversion darwin amd64
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-darwin-amd64
path: jjversion-${{ env.VERSION }}-darwin-amd64/
- name: Download jjversion windows x64
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-windows-x64
path: jjversion-${{ env.VERSION }}-windows-x64/
- name: Download jjversion windows 386
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-windows-386
path: jjversion-${{ env.VERSION }}-windows-386/
- name: Download jjversion windows arm
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
name: jjversion-${{ env.VERSION }}-windows-arm
path: jjversion-${{ env.VERSION }}-windows-arm/

# Prepare directories - copy README.md, LICENSE.md, and docs (attributions)
- run: cp README.md jjversion-${{ env.VERSION }}-linux-x64/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-linux-x64/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-x64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-linux-arm64/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-linux-arm64/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-arm64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-linux-arm/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-linux-arm/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-arm/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-linux-386/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-linux-386/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-linux-386/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-darwin-amd64/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-darwin-amd64/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-darwin-amd64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-windows-x64/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-windows-x64/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-windows-x64/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-windows-386/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-windows-386/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-windows-386/jjversion-docs
- run: cp README.md jjversion-${{ env.VERSION }}-windows-arm/jjversion-README.md
- run: cp LICENSE.md jjversion-${{ env.VERSION }}-windows-arm/jjversion-LICENSE.md
- run: cp -R docs jjversion-${{ env.VERSION }}-windows-arm/jjversion-docs

- run: zip -r jjversion-${{ env.VERSION }}-docs.zip docs
- run: zip -r jjversion-${{ env.VERSION }}-linux-x64.zip jjversion-${{ env.VERSION }}-linux-x64
- run: zip -r jjversion-${{ env.VERSION }}-linux-arm64.zip jjversion-${{ env.VERSION }}-linux-arm64
- run: zip -r jjversion-${{ env.VERSION }}-linux-arm.zip jjversion-${{ env.VERSION }}-linux-arm
- run: zip -r jjversion-${{ env.VERSION }}-linux-386.zip jjversion-${{ env.VERSION }}-linux-386
- run: zip -r jjversion-${{ env.VERSION }}-darwin-amd64.zip jjversion-${{ env.VERSION }}-darwin-amd64
- run: zip -r jjversion-${{ env.VERSION }}-windows-x64.zip jjversion-${{ env.VERSION }}-windows-x64
- run: zip -r jjversion-${{ env.VERSION }}-windows-386.zip jjversion-${{ env.VERSION }}-windows-386
- run: zip -r jjversion-${{ env.VERSION }}-windows-arm.zip jjversion-${{ env.VERSION }}-windows-arm

- run: zip jjversion-${{ env.VERSION }}-artifacts.zip jjversion-${{ env.VERSION }}-linux-x64.zip jjversion-${{ env.VERSION }}-linux-arm64.zip jjversion-${{ env.VERSION }}-linux-arm.zip jjversion-${{ env.VERSION }}-linux-386.zip jjversion-${{ env.VERSION }}-darwin-amd64.zip jjversion-${{ env.VERSION }}-windows-x64.zip jjversion-${{ env.VERSION }}-windows-386.zip jjversion-${{ env.VERSION }}-windows-arm.zip
- run: ls -R
- name: Upload jjversion
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
with:
name: jjversion-${{ env.VERSION }}-artifacts.zip
path: jjversion-${{ env.VERSION }}-artifacts.zip

- name: Download jjversion.tar
uses: actions/download-artifact@f023be2c48cc18debc3bacd34cb396e0295e2869
with:
Expand All @@ -245,17 +314,20 @@ jobs:
- run: docker tag jjliggett/jjversion "ghcr.io/jjliggett/jjversion:${{ env.VERSION }}"
- run: docker tag jjliggett/jjversion "ghcr.io/jjliggett/jjversion:latest"
- run: docker images

- run: echo "The Docker image with this version has not been published yet. The image will be uploaded on the root branch."
if: ${{ env.VERSION != env.PREVIOUS_COMMIT_VERSION }}
- run: echo "The Docker image with this version has already been published. The image will not be uploaded on the root branch."
if: ${{ env.VERSION == env.PREVIOUS_COMMIT_VERSION }}

- name: Login to GitHub Container Registry
uses: docker/login-action@42d299face0c5c43a0487c477f595ac9cf22f1a7
if: ${{ github.ref == 'refs/heads/root' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: docker push "ghcr.io/jjliggett/jjversion:${{ env.VERSION }}"
if: ${{ github.ref == 'refs/heads/root' && env.VERSION != env.PREVIOUS_COMMIT_VERSION }}
- run: docker push "ghcr.io/jjliggett/jjversion:latest"
Expand All @@ -272,6 +344,24 @@ jobs:
- run: docker push jjliggett/jjversion
if: ${{ github.ref == 'refs/heads/root' && env.VERSION != env.PREVIOUS_COMMIT_VERSION }}

- name: Create GitHub release
uses: marvinpinto/action-automatic-releases@d68defdd11f9dcc7f52f35c1b7c236ee7513bcc1
if: ${{ github.ref == 'refs/heads/root' && env.VERSION != env.PREVIOUS_COMMIT_VERSION }}
with:
automatic_release_tag: v${{ env.VERSION }}
files: |
jjversion-${{ env.VERSION }}-linux-x64.zip
jjversion-${{ env.VERSION }}-linux-arm64.zip
jjversion-${{ env.VERSION }}-linux-arm.zip
jjversion-${{ env.VERSION }}-linux-386.zip
jjversion-${{ env.VERSION }}-darwin-amd64.zip
jjversion-${{ env.VERSION }}-windows-x64.zip
jjversion-${{ env.VERSION }}-windows-386.zip
jjversion-${{ env.VERSION }}-windows-arm.zip
README.md
LICENSE.md
jjversion-${{ env.VERSION }}-docs.zip
test-release-branch:
runs-on: ubuntu-latest
needs: initial-build
Expand Down
1 change: 1 addition & 0 deletions docs/ATTRIBUTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Note, VS Code Dev Containers is a development tool that utilizes a Docker contai
- <https://github.com/docker/login-action>
- <https://github.com/github/codeql-action>
- <https://github.com/stuartleeks/devcontainer-build-run>
- <https://github.com/marvinpinto/action-automatic-releases>

The following extensions are included as part of the dev container:

Expand Down

0 comments on commit 21b6691

Please sign in to comment.