Skip to content

Commit

Permalink
Add PDF files to release candidates and releases
Browse files Browse the repository at this point in the history
  • Loading branch information
programming-wolf committed Jan 19, 2021
1 parent 3033037 commit db1a403
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/build_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: Create New Release
if: startsWith(github.ref, 'refs/tags/')
id: create_release
id: create-release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
Expand All @@ -57,21 +57,34 @@ jobs:
rm -rf ./build/tmp
cp ./docs-ext/curriculum-*.pdf ./build 2>/dev/null || :
zip -r release.zip ./build
mkdir release_dir
cp ./build/curriculum-*.pdf ./release_dir 2>/dev/null || :
mv release.zip ./release_dir/release-${{ env.RELEASE_VERSION }}.zip
- name: Deploy
if: startsWith(github.ref, 'refs/tags/')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: Publish Release ${{ env.RELEASE_VERSION }}
- name: Upload Release Files
if: startsWith(github.ref, 'refs/tags/')
id: upload-release-asset
uses: actions/upload-release-asset@v1
id: upload-release-assets
uses: actions/github-script@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./release.zip
asset_name: release-${{ env.RELEASE_VERSION }}.zip
asset_content_type: application/zip
script: |
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
for (let file of await fs.readdir('./release_dir')) {
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: ${{ steps.create-release.outputs.id }},
name: file,
data: await fs.readFile(`./release_dir/${file}`)
});
}
27 changes: 19 additions & 8 deletions .github/workflows/build_releasecandidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ jobs:
rm -rf ./build/tmp
cp ./docs-ext/curriculum-*.pdf ./build 2>/dev/null || :
zip -r release.zip ./build
- name: Deploy Release Candidate
mkdir release_dir
cp ./build/curriculum-*.pdf ./release_dir 2>/dev/null || :
mv release.zip ./release_dir/release-${{ env.RELEASE_VERSION }}.zip
- name: Deploy Release Candidate to GitHub Pages
if: startsWith(github.ref, 'refs/tags/')
uses: peaceiris/actions-gh-pages@v3
with:
Expand All @@ -67,14 +70,22 @@ jobs:
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: Publish Release Candidate ${{ env.RELEASE_VERSION }}
- name: Upload Release Files
- name: Upload Release Candidate Files
if: startsWith(github.ref, 'refs/tags/')
id: upload-release-candidate-asset
uses: actions/upload-release-asset@v1
id: upload-release-candidate-assets
uses: actions/github-script@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release-candidate.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./release.zip
asset_name: release-${{ env.RELEASE_VERSION }}.zip
asset_content_type: application/zip
script: |
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
for (let file of await fs.readdir('./release_dir')) {
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: ${{ steps.create-release-candidate.outputs.id }},
name: file,
data: await fs.readFile(`./release_dir/${file}`)
});
}

0 comments on commit db1a403

Please sign in to comment.